body {
    direction: rtl;
    text-align: right;
    background: #f4f6fb !important;
    overflow-x: hidden;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

.nav-toggle {
    display: none;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.16);
    color: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 1.35rem;
    cursor: pointer;
}

.navbar-container {
    flex-wrap: wrap;
    gap: 14px;
}

.navbar-menu {
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.advanced-menu > li {
    position: relative;
}

.navbar-menu a.active,
.navbar-menu a:hover {
    background: rgba(255,255,255,0.22) !important;
}

.nav-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 14px 35px rgba(16, 24, 40, 0.18);
    padding: 8px;
    display: none;
    z-index: 999;
}

.nav-group > a {
    cursor: default;
}

.nav-dropdown a {
    color: #344054 !important;
    padding: 11px 12px !important;
    border-radius: 10px !important;
    display: block !important;
}

.nav-dropdown a:hover,
.nav-dropdown a.active {
    background: #eef2ff !important;
    color: #4755d6 !important;
}

.nav-group:hover .nav-dropdown {
    display: block;
}

.navbar-user a {
    color: #fff;
    text-decoration: none;
}

.compact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.smart-workflow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, #182848 0%, #667eea 100%);
    color: #fff;
    border-radius: 22px;
    padding: 28px;
    margin-bottom: 30px;
    box-shadow: 0 16px 40px rgba(24, 40, 72, 0.22);
}

.workflow-badge {
    display: inline-block;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: 999px;
    padding: 7px 14px;
    margin-bottom: 12px;
}

.workflow-content h2 { margin: 0 0 8px; font-size: 1.7rem; }
.workflow-content p { margin: 0; color: rgba(255,255,255,0.86); }
.workflow-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 25px;
    margin-bottom: 25px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    color: #344054;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    padding: 11px 12px;
    font-family: inherit;
    background: #fff;
}

.form-group textarea {
    min-height: 96px;
    resize: vertical;
}

.hint-box {
    background: #eff8ff;
    color: #175cd3;
    border: 1px solid #b2ddff;
    padding: 13px 16px;
    border-radius: 12px;
    margin: 12px 0 18px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    text-decoration: none;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
}

.btn-sm { padding: 7px 11px; font-size: 0.88rem; }
.btn-primary { background: #667eea; }
.btn-success { background: #12b76a; }
.btn-secondary { background: #475467; }
.btn-warning { background: #f79009; }
.btn-danger { background: #d92d20; }
.btn-light { background: #eef2ff; color: #344054; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.62);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 5000;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: #fff;
    border-radius: 18px;
    width: min(620px, 96vw);
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0,0,0,0.28);
    padding: 24px;
}

.modal-xl {
    width: min(980px, 96vw);
}

.map-modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.map-frame {
    width: 100%;
    min-height: 430px;
    border: 1px solid #d0d5dd;
    border-radius: 14px;
    background: #f2f4f7;
}

.modal-lg {
    width: min(920px, 96vw);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    border-bottom: 1px solid #eaecf0;
    padding-bottom: 12px;
}

.modal-header h2 {
    margin: 0;
    color: #344054;
}

.modal-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: #f2f4f7;
    color: #344054;
    font-size: 1.5rem;
    cursor: pointer;
}

.alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-weight: 700;
}

.alert-success { background: #ecfdf3; color: #027a48; border: 1px solid #abefc6; }
.alert-danger { background: #fef3f2; color: #b42318; border: 1px solid #fecdca; }

.table-responsive { overflow-x: auto; }
.instant-search-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: #f9fafb;
    border: 1px solid #eaecf0;
    border-radius: 14px;
    padding: 12px;
    margin: 0 0 14px;
}

.instant-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 240px;
    background: #fff;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    padding: 0 12px;
}

.instant-search-input-wrap input {
    width: 100%;
    border: 0;
    outline: 0;
    padding: 11px 0;
    font-family: inherit;
    background: transparent;
}

.instant-search-count {
    color: #667085;
    font-weight: 700;
}
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th, .data-table td { padding: 13px; border-bottom: 1px solid #eaecf0; vertical-align: middle; }
.data-table th { background: #f9fafb; color: #344054; font-weight: 800; }
.actions-cell { white-space: nowrap; display: flex; gap: 8px; }
.empty-cell { text-align: center; color: #667085; padding: 30px !important; }
.full-field { grid-column: 1 / -1; }
.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 6px 10px;
    font-weight: 800;
    font-size: 0.85rem;
}
.badge.ok { background: #ecfdf3; color: #027a48; }
.badge.warn { background: #fffaeb; color: #b54708; }
.badge.danger { background: #fef3f2; color: #b42318; }
.badge.neutral { background: #f2f4f7; color: #344054; }
.entity-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
    color: #344054;
}
.muted-line {
    display: block;
    color: #667085;
    font-size: .86rem;
    margin-top: 3px;
}
.overdue-row { background: #fff1f3; }
.late-mark { color: #d92d20; font-size: 1.15rem; }
.inline-payment-form { background: #f9fafb; border-radius: 14px; padding: 16px; }

.split-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 22px;
    align-items: start;
}

.property-group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
    margin-bottom: 25px;
}

.property-group-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fff;
    border: 1px solid #eaecf0;
    border-radius: 18px;
    padding: 18px;
    text-decoration: none;
    color: #344054;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    transition: all .2s ease;
}

.group-main-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid #eaecf0;
    padding-top: 10px;
}

.quick-modal-actions p {
    color: #667085;
    margin: 6px 0 14px;
}

.owner-select-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.owner-select-row select {
    flex: 1;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: #667085;
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.mini-stat {
    background: #fff;
    border: 1px solid #eaecf0;
    border-radius: 16px;
    padding: 18px;
    text-decoration: none;
    color: #344054;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.mini-stat strong {
    display: block;
    font-size: 1.8rem;
    color: #667eea;
}

.mini-stat span {
    color: #667085;
    font-weight: 700;
}

.mini-stat.active {
    border-color: #667eea;
    background: #eef2ff;
}

.report-kpis,
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.kpi-card {
    background: #fff;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    border: 1px solid #eaecf0;
}

.kpi-card span,
.kpi-card small {
    color: #667085;
    font-weight: 700;
}

.kpi-card strong {
    display: block;
    font-size: 2rem;
    color: #344054;
    margin: 8px 0;
}

.report-print-paper {
    background: transparent;
}

.report-print-header {
    display: none;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 2px solid #111827;
    margin-bottom: 18px;
    padding-bottom: 14px;
}

.report-print-header h1 {
    margin: 0 0 8px;
    color: #111827;
}

.report-print-meta {
    display: grid;
    gap: 6px;
    min-width: 260px;
    font-weight: 700;
}

.progress {
    height: 9px;
    background: #eef2ff;
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0;
}

.progress i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #12b76a, #667eea);
}

.property-group-card:hover,
.property-group-card.active {
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(102,126,234,0.16);
}

.group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.08rem;
    margin-bottom: 8px;
}

.property-group-card p {
    color: #667085;
    min-height: 42px;
    margin: 0 0 12px;
}

.group-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .9rem;
}

.group-stats span {
    background: #f2f4f7;
    border-radius: 999px;
    padding: 5px 9px;
}

.ok-text { color: #027a48; }
.danger-text { color: #b42318; }

.wizard-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.step {
    background: #fff;
    border: 1px solid #eaecf0;
    border-radius: 14px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.step strong {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef2ff;
    color: #475467;
}

.step.active strong { background: #12b76a; color: #fff; }
.premium-form { border-top: 4px solid #667eea; }

.print-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.contract-paper {
    background: #fff;
    color: #111827;
    max-width: 950px;
    margin: 0 auto 30px;
    padding: 45px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    line-height: 1.9;
}

.contract-head, .contract-meta, .signature-grid {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.contract-head { border-bottom: 3px solid #111827; padding-bottom: 18px; margin-bottom: 18px; }
.contract-head h1 { margin: 0; font-size: 2rem; }
.contract-number { text-align: center; border: 1px solid #111827; padding: 10px 18px; border-radius: 8px; }
.contract-meta { background: #f9fafb; padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; }
.contract-paper h2 { margin-top: 24px; border-right: 5px solid #667eea; padding-right: 10px; font-size: 1.25rem; }
.contract-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.contract-table th, .contract-table td { border: 1px solid #d0d5dd; padding: 10px; }
.contract-table th { background: #f3f4f6; width: 18%; }
.contract-clauses { padding-right: 22px; }
.contract-notes { border: 1px dashed #98a2b3; padding: 14px; border-radius: 8px; }
.signature-grid { margin-top: 45px; }
.signature-grid div { width: 45%; text-align: center; }
.signature-grid span { display: block; height: 55px; border-bottom: 1px solid #111827; }

@media print {
    body { background: #fff !important; }
    .navbar, footer, .no-print { display: none !important; }
    .main-container { max-width: none !important; margin: 0 !important; padding: 0 !important; }
    .contract-paper { box-shadow: none; border-radius: 0; padding: 20px; margin: 0; max-width: none; }
    .report-print-paper { background: #fff; color: #111827; padding: 10px; }
    .report-print-header { display: flex; }
    .report-print-paper .card,
    .report-print-paper .stat-card,
    .report-print-paper .kpi-card,
    .report-print-paper .table-card { box-shadow: none !important; border: 1px solid #d0d5dd !important; page-break-inside: avoid; break-inside: avoid; }
    .report-print-paper .stats-grid,
    .report-print-paper .report-kpis,
    .report-print-paper .report-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .report-print-paper .data-table { min-width: 0 !important; font-size: 11px; }
    .report-print-paper .data-table th,
    .report-print-paper .data-table td { padding: 6px; }
}

@media (min-width: 1600px) {
    .navbar-container,
    .main-container,
    footer > div {
        max-width: 1540px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    }

    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
}

@media (max-width: 1200px) {
    .navbar-container {
        padding: 12px 14px !important;
    }

    .navbar-brand {
        font-size: 1.2rem !important;
    }

    .navbar-menu a {
        padding: 9px 10px !important;
        font-size: .94rem;
    }

    .main-container {
        margin: 22px auto !important;
        padding: 0 16px !important;
    }

    .data-table {
        min-width: 700px;
    }
}

@media (max-width: 900px) {
    .navbar-container {
        display: grid !important;
        grid-template-columns: 1fr auto;
        align-items: center !important;
        gap: 10px !important;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .advanced-menu {
        grid-column: 1 / -1;
        display: none !important;
        flex-direction: column;
        width: 100%;
        gap: 8px !important;
        background: rgba(255,255,255,0.08);
        border: 1px solid rgba(255,255,255,0.16);
        border-radius: 14px;
        padding: 10px !important;
    }

    .advanced-menu.is-open {
        display: flex !important;
    }

    .advanced-menu > li {
        width: 100%;
    }

    .navbar-menu a {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-dropdown {
        position: static;
        display: block;
        margin-top: 6px;
        box-shadow: none;
        width: 100%;
        min-width: 0;
        background: rgba(255,255,255,0.96);
    }

    .navbar-user {
        grid-column: 1 / -1;
        justify-content: center;
        flex-wrap: wrap;
    }

    .compact-header,
    .smart-workflow,
    .contract-head,
    .contract-meta,
    .signature-grid {
        flex-direction: column;
        align-items: stretch;
    }

    .main-container {
        margin-top: 18px !important;
        padding: 0 12px !important;
    }

    .page-header,
    .card,
    .quick-actions {
        padding: 18px !important;
    }

    .page-header h1 {
        font-size: 1.45rem;
    }

    .stats-grid,
    .actions-grid,
    .property-group-grid,
    .report-kpis,
    .report-grid,
    .wizard-steps,
    .split-grid,
    .mini-stats {
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        padding: 18px !important;
        gap: 14px !important;
    }

    .stat-icon {
        width: 62px !important;
        height: 62px !important;
        font-size: 2.2rem !important;
        flex: 0 0 auto;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .owner-select-row {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions,
    .page-actions,
    .workflow-actions,
    .card-actions,
    .print-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
        min-height: 42px;
    }

    .table-responsive {
        margin: 0 -6px;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 640px;
        font-size: .9rem;
    }

    .actions-cell {
        flex-direction: column;
        white-space: normal;
    }

    .actions-cell .btn {
        width: 100%;
    }

    .instant-search-box {
        align-items: stretch;
    }

    .instant-search-input-wrap {
        min-width: 0;
        width: 100%;
    }

    .modal-overlay {
        align-items: flex-start;
        padding: 10px;
        overflow-y: auto;
    }

    .modal-box,
    .modal-lg,
    .modal-xl {
        width: 100%;
        max-height: none;
        padding: 16px;
        border-radius: 14px;
        margin: 10px 0;
    }

    .map-frame {
        min-height: 320px;
    }

    .contract-paper {
        padding: 18px;
        overflow-x: auto;
    }

    .contract-head h1 {
        font-size: 1.45rem;
    }

    .signature-grid div {
        width: 100%;
    }
}

@media (max-width: 520px) {
    body {
        font-size: 14px;
    }

    .navbar-brand {
        font-size: 1rem !important;
        line-height: 1.5;
    }

    .main-container {
        padding: 0 8px !important;
    }

    .page-header,
    .card,
    .quick-actions,
    .smart-workflow {
        padding: 14px !important;
        border-radius: 12px !important;
    }

    .page-header h1,
    .quick-actions h2,
    .workflow-content h2 {
        font-size: 1.25rem !important;
    }

    .stat-card {
        align-items: flex-start !important;
    }

    .stat-info h3,
    .mini-stat strong,
    .kpi-card strong {
        font-size: 1.35rem !important;
        word-break: break-word;
    }

    .action-icon {
        font-size: 2.2rem !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 10px;
    }

    .data-table {
        min-width: 560px;
        font-size: .84rem;
    }

    .data-table th,
    .data-table td {
        padding: 9px;
    }

    .contract-table {
        min-width: 560px;
    }

    footer {
        margin-top: 24px !important;
        padding: 20px 0 !important;
    }
}

@media (max-width: 360px) {
    .data-table,
    .contract-table {
        min-width: 520px;
    }

    .badge {
        font-size: .76rem;
        padding: 5px 8px;
    }
}