/* =========================================================
   מערכת ניהול נכסים - עיצוב ראשי
   RTL + Dark/Light Mode מבוסס CSS Variables
   ========================================================= */

:root {
    --font-main: 'Segoe UI', 'Assistant', Tahoma, Arial, sans-serif;

    --color-bg: #f5f7fa;
    --color-surface: #ffffff;
    --color-surface-2: #f9fafb;
    --color-border: #e2e8f0;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;

    --color-primary: #0a2138;
    --color-primary-hover: #16324d;
    --color-primary-light: #e8edf2;

    --color-success: #16a34a;
    --color-success-bg: #dcfce7;
    --color-warning: #d97706;
    --color-warning-bg: #fef3c7;
    --color-info: #0284c7;
    --color-info-bg: #e0f2fe;
    --color-danger: #dc2626;
    --color-danger-bg: #fee2e2;
    --color-secondary-bg: #f1f5f9;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    --color-bg: #0f1117;
    --color-surface: #1a1d27;
    --color-surface-2: #20232f;
    --color-border: #2d3142;
    --color-text: #e5e7eb;
    --color-text-muted: #9096a8;

    --color-primary: #6366f1;
    --color-primary-hover: #818cf8;
    --color-primary-light: #232544;

    --color-success-bg: #123625;
    --color-warning-bg: #3a2a10;
    --color-info-bg: #10293a;
    --color-danger-bg: #3a1414;
    --color-secondary-bg: #262a38;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    direction: rtl;
    text-align: right;
    font-size: 15px;
    transition: background .2s, color .2s;
    overflow-x: hidden;
    width: 100%;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    padding: 20px 14px;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    overflow-y: auto;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 700;
    padding: 8px 10px 20px;
    color: var(--color-primary);
}

.nav-group { margin-bottom: 6px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}
.nav-link:hover { background: var(--color-surface-2); color: var(--color-text); }
.nav-link.active { background: var(--color-primary-light); color: var(--color-primary); }
.nav-icon { width: 18px; text-align: center; }

/* תת-תפריט מתקפל (למשל "הגדרות") */
.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 2px;
    text-align: right;
}
.nav-group-toggle:hover { background: var(--color-surface-2); color: var(--color-text); }
.nav-group-toggle.nav-group-open { color: var(--color-text); }
.nav-group-chevron { transition: transform .2s; font-size: 12px; }
.nav-group-toggle.nav-group-open .nav-group-chevron { transform: rotate(180deg); }
.nav-submenu {
    display: none;
    flex-direction: column;
    padding-right: 30px;
    margin-bottom: 4px;
}
.nav-submenu.open { display: flex; }
.nav-sublink {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 13px;
    margin-bottom: 2px;
}
.nav-sublink:hover { background: var(--color-surface-2); color: var(--color-text); }
.nav-sublink.active { background: var(--color-primary-light); color: var(--color-primary); font-weight: 600; }
@media (max-width: 900px) {
    /* במובייל מגדילים מעט את שטח הלחיצה לנוחות אצבע */
    .nav-group-toggle, .nav-sublink { padding: 13px 12px; font-size: 15px; }
}

.main-content {
    margin-right: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-search {
    flex: 1;
    max-width: 360px;
}
.topbar-search input {
    width: 100%;
}

.topbar-actions { display: flex; align-items: center; gap: 14px; }

.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
}

.page-body { padding: 24px; flex: 1; }

.sidebar-mobile-header {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 39;
}
.sidebar-overlay.active { display: block; }

button.mobile-menu-btn { display: none; }

@media (max-width: 900px) {
    html, body { overflow-x: hidden; }
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .main-content { margin-right: 0; }
    button.mobile-menu-btn { display: inline-flex; }
    .topbar-search { display: none; }
    .topbar-search.mobile-open { display: block; position: absolute; top: 60px; right: 12px; left: 12px; z-index: 20; background: var(--color-surface); padding: 8px; border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
    .mobile-search-btn { display: inline-flex; }

    .sidebar-mobile-header {
        display: flex;
        justify-content: flex-start;
        margin-bottom: 10px;
    }
    .sidebar-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: 1px solid var(--color-border);
        background: var(--color-surface-2);
        color: var(--color-text);
        font-size: 16px;
        cursor: pointer;
        padding: 0;
    }

    .topbar {
        flex-wrap: nowrap;
        height: 60px;
        min-height: 60px;
        padding: 8px 12px;
        gap: 8px;
    }
    .topbar-mobile-controls { flex: 0 0 auto; gap: 6px; }
    .topbar-actions {
        flex: 1 1 auto;
        min-width: 0;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 7px;
    }
    .topbar-user { min-width: 0; gap: 6px; }
    .topbar-user-copy { min-width: 0; max-width: 110px; }
    .topbar-user-copy .font-bold {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .topbar-user-copy > .text-muted { display: none; }
    .topbar .avatar { width: 34px; height: 34px; flex: 0 0 34px; }
    .topbar .theme-toggle { width: 38px; height: 38px; flex: 0 0 38px; }
    .topbar .mobile-menu-btn,
    .topbar .mobile-search-btn {
        width: 40px;
        height: 40px;
        min-height: 40px;
        padding: 0;
        justify-content: center;
        flex: 0 0 40px;
    }

    .fx-ticker {
        width: auto;
        min-width: 0;
        justify-content: flex-start;
        font-size: 11px;
        padding: 3px 10px;
        gap: 6px;
        opacity: .8;
    }
}
@media (min-width: 901px) { .mobile-search-btn { display: none; } }
@media (max-width: 600px) {
    .topbar { padding-inline: 8px; gap: 4px; }
    .topbar-mobile-controls { gap: 4px; }
    .topbar-actions { gap: 4px; }
    .topbar .mobile-menu-btn,
    .topbar .mobile-search-btn { width: 36px; height: 36px; min-height: 36px; flex-basis: 36px; }
    .topbar .theme-toggle { width: 34px; height: 34px; flex-basis: 34px; }
    .topbar .avatar { width: 32px; height: 32px; flex-basis: 32px; }
    .topbar-user { gap: 4px; }
    .topbar-user-copy { max-width: 58px; }
    .topbar-user-copy .font-bold { font-size: 11px; }
    .topbar .fx-ticker {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 0;
        border-radius: 8px;
        padding: 2px 5px;
        font-size: 9px;
        line-height: 1.25;
        white-space: nowrap;
    }
    .topbar .fx-stale-dot { display:none; }
}

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-grid > * { min-width: 0; max-width: 100%; }

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
}
.stat-card .stat-label { color: var(--color-text-muted); font-size: 13px; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; text-align: right; unicode-bidi: plaintext; }
.stat-card .stat-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* מניעת שבירת סכומים/מטבעות לכמה שורות בתוך טבלאות RTL (סעיף 15 בדוח) */
table td.amount-cell, .mini-payment-amount, .mini-payment-balance {
    white-space: nowrap;
    direction: ltr;
    unicode-bidi: plaintext;
    text-align: right;
}

.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }
@media (max-width: 480px) {
    /* שני כרטיסי מדד בשורה במקום עמודה אחת ארוכה (סעיף 17 בדוח) */
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 100%; }
    .stat-card { padding: 12px 10px; }
    .stat-card .stat-value { font-size: 17px; }
    .stat-card .stat-label { font-size: 11px; }
}

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="month"], input[type="search"],
select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-text);
    font-family: inherit;
    font-size: 14px;
    height: 42px;
    box-sizing: border-box;
}
textarea { height: auto; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
}
.field-error { color: var(--color-danger); font-size: 12px; margin-top: 4px; }
.field-hint { color: var(--color-text-muted); font-size: 12px; margin-top: 4px; }

/* Investment and ownership workspace */
.selection-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:10px; }
.selection-card { display:flex; align-items:center; gap:9px; padding:10px 12px; border:1px solid var(--color-border); border-radius:var(--radius-sm); background:var(--color-surface-2); cursor:pointer; }
.selection-card input { width:auto; flex:0 0 auto; }
.selection-master { margin-bottom:10px; width:max-content; max-width:100%; }
.form-card-narrow { max-width:900px; }
.action-wrap { flex-wrap:wrap; }
.investment-property-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:14px; }
.investment-property-card { color:inherit; text-decoration:none; min-width:0; }
.investment-property-card:hover { border-color:var(--color-primary); box-shadow:var(--shadow-md); }
.investment-mini-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.investment-mini-grid span { padding:8px; border-radius:8px; background:var(--color-surface-2); min-width:0; }
.investment-mini-grid small,.investment-mini-grid strong { display:block; }
.investment-mini-grid small { color:var(--color-text-muted); font-size:11px; }
.investment-mini-grid strong { margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.investment-status-bar { padding:12px 15px; margin-bottom:18px; border-radius:var(--radius-md); background:var(--color-primary-light); color:var(--color-primary); }
.section-heading { display:flex; align-items:end; justify-content:space-between; gap:12px; margin:20px 0 9px; color:var(--color-text-muted); }
.section-heading span { color:var(--color-text); font-weight:700; }
.section-heading small { font-size:11px; }
.investment-stats { margin-bottom:12px; }
.stat-emphasis { border-right:4px solid var(--color-primary); }
.text-success { color:var(--color-success) !important; }
.text-danger { color:var(--color-danger) !important; }
.text-warning { color:var(--color-warning) !important; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-secondary-bg); color: var(--color-text); }
.btn-secondary:hover { filter: brightness(0.95); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-info    { background: var(--color-info-bg); color: var(--color-info); }
.badge-danger  { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-secondary { background: var(--color-secondary-bg); color: var(--color-text-muted); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: right;
    padding: 12px 14px;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tbody tr:hover { background: var(--color-surface-2); }
tbody tr:last-child td { border-bottom: none; }
tfoot td { padding: 12px 14px; font-weight: 700; background: var(--color-surface-2); }

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.btn-filter-toggle {
    background: var(--color-primary-hover);
    color: #fff;
}
.btn-filter-toggle:hover { filter: brightness(1.08); }

.filters-toggle-btn { display: none; }

@media (max-width: 900px) {
    .filters-toggle-btn {
        display: flex;
        width: 100%;
        justify-content: center;
        margin-bottom: 12px;
    }
    .filters-panel { display: none; }
    .filters-panel.open { display: block; }
}

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px;
    background: var(--color-primary-light); color: var(--color-primary);
    font-size: 13px; font-weight: 600;
}
.chip button { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px; padding: 0; }

/* ---------- Alerts / Flash ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.alert-info { background: var(--color-info-bg); color: var(--color-info); }

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 13px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; }

.skeleton {
    background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border) 37%, var(--color-surface-2) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
}
.auth-logo { text-align: center; font-size: 20px; font-weight: 700; color: var(--color-primary); margin-bottom: 24px; }

.theme-toggle {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 16px;
}

.fx-ticker {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--color-text-muted);
    cursor: default;
}
.fx-pair { white-space: nowrap; }
.fx-pair b { color: var(--color-text); font-weight: 700; }
.fx-stale-dot { color: var(--color-warning); font-size: 13px; }

.recent-cards-mobile { display: none; }

.mini-payment-card {
    display: block;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
    background: var(--color-surface);
}
.mini-payment-card:hover { background: var(--color-surface-2); }
.mini-payment-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.mini-payment-desc { font-weight: 700; font-size: 14px; }
.mini-payment-meta { font-size: 12px; color: var(--color-text-muted); margin-bottom: 6px; }
.mini-payment-amount { font-weight: 700; font-size: 16px; color: var(--color-primary); }

@media (max-width: 900px) {
    .recent-table-desktop { display: none; }
    .recent-cards-mobile { display: block; }
}

.payments-cards-mobile { display: none; }
.col-extra { display: none; }
.show-extra-cols .col-extra { display: table-cell; }

.mini-payment-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}
.mini-payment-balance { font-size: 12px; color: var(--color-warning); font-weight: 600; }

@media (max-width: 900px) {
    .payments-table-desktop { display: none; }
    .payments-cards-mobile { display: block; }
    .mobile-card-table { min-width: 0 !important; width: 100%; }
    .mobile-card-table thead { display: none; }
    .mobile-card-table tbody, .mobile-card-table tr, .mobile-card-table td { display: block; width: 100%; }
    .mobile-card-table tr { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 10px; }
    .mobile-card-table td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; }
    .mobile-card-table td::before { content: attr(data-label); color: var(--color-text-muted); font-size: 12px; font-weight: 600; text-align: right; }
    .mobile-card-table td[colspan] { display: block; }
    .mobile-card-table td[colspan]::before { display: none; }
    .mobile-card-table .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .rental-period-filter .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .rental-period-filter .form-group { min-width: 0; }
    .rental-period-filter .form-group:last-child { grid-column: 1 / -1; }
    .secondary-metrics { min-width: 0; max-width: 100%; overflow: hidden; }
    .secondary-metrics .stat-grid { min-width: 0; width: 100%; max-width: 100%; }
}

@media (max-width: 600px) {
    .page-body { padding: 12px; }
    .portal-body { padding: 14px 12px !important; }
    .portal-nav { padding: 0 12px !important; gap: 8px; }
    .portal-nav > .font-bold { flex: 1 1 auto; min-width: 0; gap: 5px; }
    .portal-nav > .font-bold img { max-width: 92px !important; height: 30px !important; }
    .portal-nav > .font-bold > span { font-size: 11px; white-space: nowrap; }
    .portal-menu-btn { flex: 0 0 40px; }
    .card { padding: 14px; }
    .page-header { align-items: flex-start; gap: 10px; }
    .page-header > .flex {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .page-header > .flex > .btn {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 9px 10px;
        justify-content: center;
        text-align: center;
        white-space: normal;
        line-height: 1.25;
    }
    .page-body .flex.gap-2:has(> .btn),
    .page-body .flex.gap-3:has(> .btn),
    .portal-body .flex.gap-2:has(> .btn),
    .portal-body .flex.gap-3:has(> .btn) { flex-wrap: wrap; }
    .page-body .flex.gap-2:has(> .btn) > .btn,
    .page-body .flex.gap-3:has(> .btn) > .btn,
    .portal-body .flex.gap-2:has(> .btn) > .btn,
    .portal-body .flex.gap-3:has(> .btn) > .btn {
        flex: 1 1 135px;
        min-height: 44px;
        min-width: 0;
        padding-inline: 10px;
        justify-content: center;
        text-align: center;
        white-space: normal;
        line-height: 1.25;
    }
    .form-row { grid-template-columns: 1fr; gap: 10px; }
    .rental-period-filter .form-row { grid-template-columns: 1fr; }
    .rental-period-filter .form-group:last-child { grid-column: auto; }
    .table-wrap { max-width: 100%; }
    .investment-property-grid { grid-template-columns:1fr; }
    .investment-mini-grid { grid-template-columns:1fr 1fr; }
    .action-wrap { width:100%; }
    .action-wrap > .btn { flex:1 1 140px; min-height:44px; justify-content:center; white-space:normal; }
    .mobile-card-table input[type="number"], .mobile-card-table select { max-width:170px; }
}

/* ---------- Tasks ---------- */
.task-quick-views {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}
.task-quick-view {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 64px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-muted);
}
.task-quick-view strong { font-size: 21px; color: var(--color-text); }
.task-quick-view:hover, .task-quick-view.active { border-color: var(--color-primary); background: var(--color-primary-light); color: var(--color-primary); }
.task-row-overdue td:first-child { border-right: 4px solid var(--color-danger); }
.task-cards-mobile { display: none; }
.task-mobile-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.task-mobile-card.overdue { border-right: 4px solid var(--color-danger); }
.task-mobile-entities { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; color: var(--color-primary); }
.task-mobile-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; color: var(--color-text-muted); font-size: 13px; }
.task-checkbox { min-height: 42px; display: flex; align-items: center; gap: 8px; font-weight: 400; }
.task-checkbox input { width: auto; }
.form-static-value { min-height: 42px; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-2); }
.task-entity-list { display: flex; flex-direction: column; gap: 8px; }
.task-entity-link { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.task-entity-link:hover { background: var(--color-surface-2); border-color: var(--color-primary); }
.task-activity-list { display: flex; flex-direction: column; }
.task-activity-row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--color-border); }
.task-activity-row:last-child { border-bottom: 0; }
.task-status-actions form { display: inline-flex; }
.task-dashboard-counts { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.task-dashboard-counts a { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: var(--radius-sm); background: var(--color-surface-2); }
.task-dashboard-counts strong { font-size: 20px; }
.task-dashboard-list { display: flex; flex-direction: column; }
.task-dashboard-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 12px; border-top: 1px solid var(--color-border); }
.task-dashboard-row:hover { background: var(--color-surface-2); }
.task-dashboard-row.overdue { border-right: 3px solid var(--color-danger); color: var(--color-danger); }

@media (max-width: 1100px) {
    .task-quick-views { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .task-table-desktop { display: none; }
    .task-cards-mobile { display: block; }
}
@media (max-width: 600px) {
    .task-quick-views { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .task-quick-view { min-height: 58px; padding: 10px 12px; }
    .task-mobile-meta { grid-template-columns: 1fr; }
    .task-entity-link { grid-template-columns: 1fr auto; }
    .task-entity-link .text-muted { grid-column: 1 / -1; }
    .task-status-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); width: 100%; }
    .task-status-actions form, .task-status-actions .btn { width: 100%; }
    .task-dashboard-row { align-items: flex-start; flex-direction: column; gap: 4px; }
}
