/* نظام إدارة اتحاد الشاغلين - التصميم الرئيسي */
/* Bootstrap Overrides */
body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text-strong);
}

/* Sidebar responsive — unified with JS (.active) */
@media (max-width: 767.98px) {
    .sidebar.show,
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-right: 0;
    }
}

/* Bootstrap buttons customization */
.btn-primary {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}
.btn-primary:hover {
    background-color: var(--brand-primary-600);
    border-color: var(--brand-primary-600);
}

/* Bootstrap card customization */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
}

:root {
    /* Brand */
    --brand-primary: #2563eb;
    --brand-primary-600: #1d4ed8;
    --brand-secondary: #06b6d4;
    --brand-accent: #8b5cf6;
    --gradient-brand: linear-gradient(135deg, #2563eb 0%, #06b6d4 50%, #8b5cf6 100%);
    --gradient-sidebar: linear-gradient(180deg, #0f172a 0%, #1e293b 55%, #0f2744 100%);

    /* Status */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #06b6d4;

    /* Surfaces */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --muted-surface: #f8fafc;
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 55%, #0f2744 100%);

    /* Text */
    --text-strong: #0f172a;
    --text-default: #334155;
    --text-muted: #64748b;

    /* Borders */
    --border: rgba(15, 23, 42, 0.08);
    --divider: rgba(15, 23, 42, 0.1);

    /* Table */
    --table-bg: var(--surface);
    --table-header-bg: #f1f5f9;
    --table-row-hover: #eff6ff;

    /* Buttons */
    --btn-primary-bg: var(--brand-primary);
    --btn-primary-color: #ffffff;
    --btn-secondary-bg: #e2e8f0;
    --btn-secondary-color: var(--text-strong);

    /* Layout */
    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;
    --header-height: 68px;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --box-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --box-shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --focus-ring: rgba(37, 99, 235, 0.25);
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.5);

    /* Stat accents — متناسقة */
    --stat-income: #10b981;
    --stat-expense: #f43f5e;
    --stat-fund: #06b6d4;
    --stat-dues: #f59e0b;
}

/* Dark theme overrides: not pure black, lower contrast */
[data-theme="dark"] {
    --brand-primary: #60a5fa;
    --brand-primary-600: #3b82f6;
    --brand-secondary: #22d3ee;
    --brand-accent: #a78bfa;
    --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #22d3ee 50%, #a78bfa 100%);
    --gradient-sidebar: linear-gradient(180deg, #020617 0%, #0f172a 55%, #0c1a2e 100%);

    --color-success: #34d399;
    --color-warning: #fbbf24;
    --color-danger: #f87171;
    --color-info: #22d3ee;

    --bg: #0b1120;
    --surface: #111827;
    --surface-elevated: #1e293b;
    --muted-surface: #0f172a;
    --sidebar-bg: linear-gradient(180deg, #020617 0%, #0f172a 55%, #0c1a2e 100%);

    --text-strong: #f1f5f9;
    --text-default: #cbd5e1;
    --text-muted: #94a3b8;

    --border: rgba(255, 255, 255, 0.06);
    --divider: rgba(255, 255, 255, 0.08);

    --table-bg: var(--surface);
    --table-header-bg: #0f172a;
    --table-row-hover: rgba(96, 165, 250, 0.06);

    --btn-primary-bg: var(--brand-primary);
    --btn-primary-color: #0f172a;
    --btn-secondary-bg: #1e293b;
    --btn-secondary-color: var(--text-strong);
    --focus-ring: rgba(96, 165, 250, 0.2);
    --box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --box-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
    --glass-bg: rgba(17, 24, 39, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
}

/* Backwards-compatible aliases (legacy tokens) */
:root {
    --primary-color: var(--brand-primary);
    --secondary-color: var(--brand-secondary);
    --success-color: var(--color-success);
    --warning-color: var(--color-warning);
    --danger-color: var(--color-danger);
    --info-color: var(--color-info);
    --bg-color: var(--bg);
    --text-color: var(--text-default);
    --card-bg: var(--surface);
    --table-row-hover-bg: var(--table-row-hover);
    --light-color: var(--muted-surface);
    --dark-color: var(--text-strong);
}

[data-theme="dark"] {
    --primary-color: var(--brand-primary);
    --secondary-color: var(--brand-secondary);
    --success-color: var(--color-success);
    --warning-color: var(--color-warning);
    --danger-color: var(--color-danger);
    --info-color: var(--color-info);
    --bg-color: var(--bg);
    --text-color: var(--text-default);
    --card-bg: var(--surface);
    --table-row-hover-bg: var(--table-row-hover);
    --light-color: var(--muted-surface);
    --dark-color: var(--text-strong);
}

/* extra styling to override dark mode for elements that don't use variables */
[data-theme="dark"] .sidebar {
    background: var(--sidebar-bg);
    color: var(--text-strong);
}
[data-theme="dark"] .sidebar a {
    color: rgba(255,255,255,0.88);
}
[data-theme="dark"] .sidebar a:hover,
[data-theme="dark"] .sidebar.active a {
    background: rgba(255,255,255,0.04);
}
[data-theme="dark"] .header {
    background: var(--surface-elevated);
    color: var(--text-default);
}
[data-theme="dark"] .header .header-icon,
[data-theme="dark"] .theme-toggle {
    color: var(--text-default);
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text-strong);
    line-height: 1.6;
    direction: rtl;
    transition: background-color 0.25s ease, color 0.25s ease;
    -webkit-font-smoothing: antialiased;
}

.app-body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(37, 99, 235, 0.08), transparent),
        var(--bg);
}

/* Theme toggle switch (header) */
.theme-toggle {
    cursor: pointer;
    font-size: 1.2rem;
    padding: 6px 10px;
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--text-color);
    transition: var(--transition);
}
.theme-toggle:hover {
    background: var(--muted-surface);
}
.theme-toggle[data-active="dark"] {
    color: var(--brand-secondary);
}

/* Typography tokens */
html { font-size: 16px; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
h1 { font-size: 1.75rem; font-weight: 700; color: var(--text-strong); line-height: 1.15; }
h2 { font-size: 1.375rem; font-weight: 700; color: var(--text-strong); line-height: 1.2; }
h3 { font-size: 1.125rem; font-weight: 600; color: var(--text-strong); line-height: 1.25; }
h4,h5,h6 { font-weight: 600; color: var(--text-strong); }
p, label, span, li { color: var(--text-default); }
small, .text-muted { color: var(--text-muted); }

/* ====== تسجيل الدخول ====== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 450px;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo i {
    font-size: 60px;
    color: var(--secondary-color);
}

.login-logo h1 {
    font-size: 24px;
    color: var(--primary-color);
    margin-top: 15px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-strong);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--divider);
    border-radius: var(--border-radius);
    font-size: 15px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.input-group {
    position: relative;
}

.input-group-text {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
    touch-action: manipulation;
    min-height: 44px; /* ensures tappable area on mobile */
}
.btn:active {
    transform: scale(0.97);
}
.btn:focus-visible,
.btn-action:focus-visible,
.theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring);
    border-radius: var(--border-radius);
}

/* grouping buttons together */
.btn-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
}
.btn-group .btn {
    margin: 0;
    border-radius: 0;
}
.btn-group .btn:first-child {
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}
.btn-group .btn:last-child {
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}
.btn + .btn {
    margin-left: 5px;
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-color);
}
.btn-primary:hover {
    background: var(--brand-primary-600);
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-success:hover { filter: brightness(0.95); }

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover { filter: brightness(0.95); }

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-color);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 20px;
    font-size: 13px;
}

.btn-lg {
    padding: 15px 40px;
    font-size: 16px;
}

/* ====== القائمة الجانبية ====== */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    z-index: 1050;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 16px;
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

.sidebar-header h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: #f8fafc;
    line-height: 1.4;
}

.sidebar-subtitle {
    display: block;
    font-size: 12px;
    color: rgba(226, 232, 240, 0.65);
    margin-top: 4px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-menu {
    padding: 20px 0;
}

.menu-item {
    padding: 0;
}

.menu-item a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: var(--transition);
    border-right: 3px solid transparent;
}

.menu-item a:hover,
.menu-item.active a {
    background: rgba(255,255,255,0.1);
    color: white;
    border-right-color: var(--secondary-color);
}

.menu-item i {
    width: 25px;
    margin-left: 15px;
    font-size: 18px;
}

.menu-category {
    padding: 15px 25px 10px;
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    letter-spacing: 1px;
}

.sidebar-advanced {
    margin: 0.5rem 0;
}
.sidebar-advanced summary {
    padding: 12px 25px;
    cursor: pointer;
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    list-style: none;
}
.sidebar-advanced summary::-webkit-details-marker { display: none; }
.sidebar-advanced .menu-item a {
    padding: 10px 25px 10px 40px;
    font-size: 13px;
}

/* typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-strong);
    margin: 0 0 0.5rem 0;
    line-height: 1.15;
}

/* text helpers */
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }

/* table helpers */
.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}
.table tbody tr {
    transition: background-color 0.2s ease;
}

td[data-type="number"], th[data-type="number"] {
    text-align: right;
}

/* Table readability improvements */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px; /* subtle separation between rows */
    font-size: 15px;
}
.table thead th {
    background: var(--table-header-bg);
    color: var(--text-strong);
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid var(--divider);
    text-align: left;
}
.table tbody td {
    background: var(--table-bg);
    color: var(--text-strong);
    padding: 12px 14px;
    vertical-align: middle;
}
.table tbody tr:hover td {
    background: var(--table-row-hover);
}
.table .badge {
    opacity: 0.98;
}

/* ====== المحتوى الرئيسي ====== */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    transition: var(--transition);
}

.header {
    background: var(--card-bg);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-icon {
    position: relative;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-strong);
    transition: var(--transition);
}

.header-icon:hover {
    color: var(--secondary-color);
}


.header-left {
    display: flex;
    align-items: center;
}

.toggle-sidebar {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-strong);
    margin-left: 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

@media (max-width: 768px) {
    .header-right {
        gap: 10px;
    }
}

.header-icon {
    position: relative;
    cursor: pointer;
    font-size: 20px;
    color: var(--primary-color);
}

.header-icon .badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 50%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    text-align: right;
}

.user-info h6 {
    margin: 0;
    font-size: 14px;
}

.user-info span {
    font-size: 12px;
    color: var(--text-muted);
}

/* ====== المحتوى ====== */
.content {
    padding: 30px;
}

.page-title {
    margin-bottom: 30px;
}

.page-title h2 {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.page-title p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ====== البطاقات الإحصائية ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stats-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

.stats-grid--finance {
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 16px 18px;
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.stat-card--compact {
    padding: 14px 16px;
    gap: 12px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.stat-card--compact:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.stat-card--compact::before {
    display: none;
}

.stat-card--compact.accent-income { border-right: 3px solid var(--stat-income); }
.stat-card--compact.accent-expense { border-right: 3px solid var(--stat-expense); }
.stat-card--compact.accent-fund { border-right: 3px solid var(--stat-fund); }
.stat-card--compact.accent-dues { border-right: 3px solid var(--stat-dues); }

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-brand);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-lg);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-card:not(.stat-card--compact) .stat-icon {
    width: 56px;
    height: 56px;
    font-size: 24px;
}

/* ألوان متناسقة — نفس التشبع والإضاءة */
.tone-brand { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.tone-income { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.tone-expense { background: rgba(244, 63, 94, 0.12); color: #f43f5e; }
.tone-fund { background: rgba(6, 182, 212, 0.12); color: #06b6d4; }
.tone-dues { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }

[data-theme="dark"] .tone-brand { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
[data-theme="dark"] .tone-income { background: rgba(52, 211, 153, 0.15); color: #34d399; }
[data-theme="dark"] .tone-expense { background: rgba(251, 113, 133, 0.15); color: #fb7185; }
[data-theme="dark"] .tone-fund { background: rgba(34, 211, 238, 0.15); color: #22d3ee; }
[data-theme="dark"] .tone-dues { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }

.stat-icon.primary { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.stat-icon.success { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.stat-icon.warning { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.stat-icon.danger { background: rgba(244, 63, 94, 0.12); color: #f43f5e; }
.stat-icon.info { background: rgba(6, 182, 212, 0.12); color: #06b6d4; }
.stat-icon.dark { background: rgba(100, 116, 139, 0.12); color: #64748b; }

.stat-details {
    flex: 1;
    min-width: 0;
}

.stat-details h3 {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 2px 0 0;
    color: var(--text-strong);
    line-height: 1.2;
}

.stat-card--compact .stat-details h3 {
    font-size: 1.2rem;
}

.stat-unit {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-details p {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    margin: 0;
    text-transform: none;
}

.stat-details small {
    color: var(--text-muted);
    font-size: 0.72rem;
    display: block;
    margin-top: 2px;
}

/* شبكة لوحة التحكم */
.dashboard-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.dashboard-grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

.page-title {
    margin-bottom: 20px;
}

.page-title h2 {
    font-size: 1.35rem;
    color: var(--text-strong);
    margin-bottom: 4px;
}

.page-title p {
    font-size: 0.85rem;
}

.chart-container {
    position: relative;
    height: 220px;
}

/* ====== البطاقات ====== */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h5 {
    margin: 0;
    font-size: 18px;
    color: var(--text-strong);
}

/* Page stats (compact) */
.page-stats {
    display: flex;
    gap: 12px;
    align-items: stretch;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.stat-card-small {
    background: var(--surface);
    border: 1px solid var(--divider);
    padding: 12px 14px;
    border-radius: 8px;
    min-width: 140px;
    box-shadow: none;
}
.stat-card-small h6 { margin: 0; font-size: 0.9rem; color: var(--text-muted); }
.stat-card-small p { margin: 6px 0 0 0; font-size: 1.1rem; color: var(--text-strong); font-weight: 700; }

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-bar .form-control { min-width: 160px; max-width: 220px; }
.filter-actions { margin-left: auto; display: flex; gap: 8px; }

@media (max-width: 576px) {
    .filter-bar { gap: 8px; }
    .filter-bar .form-control { min-width: 120px; max-width: 100%; flex: 1 1 auto; }
    .page-stats { gap: 8px; }
}

.card-body {
    padding: 25px;
    background: var(--card-bg);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--light-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
}

.card-header {
    background: var(--table-header-bg);
    padding: 15px 25px;
    border-bottom: 1px solid var(--light-color);
}

.card-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--light-color);
    background: var(--table-header-bg);
}


/* ====== الجداول ====== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--table-bg);
}

.table th,
.table td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--divider);
}

.table th {
    background: var(--table-header-bg);
    font-weight: 700;
    color: var(--text-strong);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--table-row-hover);
}

.table tbody tr:nth-child(even) {
    background: transparent;
}

.table img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: rgba(39, 174, 96, 0.1); color: var(--success-color); }
.badge-danger { background: rgba(231, 76, 60, 0.1); color: var(--danger-color); }
.badge-warning { background: rgba(243, 156, 18, 0.1); color: var(--warning-color); }
.badge-info { background: rgba(23, 162, 184, 0.1); color: var(--info-color); }
.badge-secondary { background: rgba(108, 117, 125, 0.06); color: var(--text-muted); }

/* badge icon indicators */
.badge-success:before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 4px; }
.badge-danger:before { content: "\f00d"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 4px; }
.badge-warning:before { content: "\f071"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 4px; }
.badge-info:before { content: "\f05a"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 4px; }
.badge-secondary:before { content: "\f128"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 4px; }

/* global icon helper */
.icon { display: inline-block; width: 1em; text-align: center; }

/* FontAwesome icons should inherit current text color unless overridden */
.fas, .far, .fal, .fab, .fa { color: inherit; }

/* mobile-card style: convert each row into a card-like block when viewport is narrow
   Requires <td data-label="Column Name"> markup so the before pseudo-element can show the header text. */
@media (max-width: 576px) {
    .table-container table,
    .table-container thead,
    .table-container tbody,
    .table-container th,
    .table-container td,
    .table-container tr {
        display: block;
    }
    .table-container thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    .table-container td {
        border: none;
        position: relative;
        padding-left: 50%;
        text-align: left;
    }
    .table-container td:before {
        position: absolute;
        top: 50%;
        left: 15px;
        transform: translateY(-50%);
        font-weight: 600;
        white-space: nowrap;
        content: attr(data-label);
        color: var(--text-muted);
    }
    .table-container {
        overflow-x: visible;
    }
}

/* ====== الأزرار في الجداول ====== */
.btn-action {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 4px;
    transition: var(--transition);
    touch-action: manipulation;
}

/* more prominent spacing on small devices */
@media (max-width: 576px) {
    .btn-action {
        width: 44px;
        height: 44px;
        margin: 0 6px;
    }
}

/* status colors for rows or labels */
.status-success { color: var(--success-color); }
.status-danger { color: var(--danger-color); }
.status-warning { color: var(--warning-color); }
.status-info { color: var(--info-color); }
.status-secondary { color: var(--text-muted); }

.btn-view { background: rgba(52, 152, 219, 0.1); color: var(--secondary-color); }
.btn-edit { background: rgba(243, 156, 18, 0.1); color: var(--warning-color); }
.btn-delete { background: rgba(231, 76, 60, 0.1); color: var(--danger-color); }
.btn-print { background: rgba(39, 174, 96, 0.1); color: var(--success-color); }

.btn-action:hover {
    transform: scale(1.1);
}

/* cell utility classes to clarify intent in markup */
.table-cell-data { }
.table-cell-status { text-align: center; }
.table-cell-actions { white-space: nowrap; }

/* spacing utilities */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }

/* empty / loading states */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-color);
}
.empty-state i {
    font-size: 48px;
    color: var(--secondary-color);
    margin-bottom: 10px;
}
.empty-state h4 {
    margin-bottom: 5px;
}

/* ====== النماذج ====== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-strong);
}

.form-control-lg {
    padding: 15px;
    font-size: 16px;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 15px center;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-check-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ====== البحث والفلترة ====== */
.search-box {
    position: relative;
    max-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid var(--divider);
    border-radius: var(--border-radius);
}

.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
    padding: 10px 15px;
    border: 2px solid var(--divider);
    border-radius: var(--border-radius);
}

/* ====== الترقيم ====== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.pagination a,
.pagination span {
    padding: 10px 15px;
    border: 1px solid var(--divider);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-strong);
    transition: var(--transition);
}

.pagination a:hover,
.pagination .active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

/* ====== التبويبات ====== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--divider);
    margin-bottom: 20px;
}

.tab {
    padding: 15px 25px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.tab.active {
    border-bottom-color: var(--secondary-color);
    color: var(--secondary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ====== التنبيهات ====== */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    position: relative;
}

.alert-success { background: rgba(39, 174, 96, 0.1); color: var(--success-color); border: 1px solid rgba(39, 174, 96, 0.3); }
.alert-danger { background: rgba(231, 76, 60, 0.1); color: var(--danger-color); border: 1px solid rgba(231, 76, 60, 0.3); }
.alert-warning { background: rgba(243, 156, 18, 0.1); color: var(--warning-color); border: 1px solid rgba(243, 156, 18, 0.3); }
.alert-info { background: rgba(23, 162, 184, 0.1); color: var(--info-color); border: 1px solid rgba(23, 162, 184, 0.3); }

.btn-close {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.5;
}

.btn-close:hover {
    opacity: 1;
}

/* ====== المودال ====== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--divider);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ====== الطباعة ====== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    .sidebar,
    .header,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-right: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ====== التصميم المتجاوب ====== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
    }
    
    .stats-grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid--2 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* desktop collapse */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed ~ .main-content,
.sidebar.collapsed + .main-content {
    margin-right: var(--sidebar-collapsed);
}

/* action menu and mobile action collapse */
.table-cell-actions {
    position: relative;
    text-align: right;
    white-space: nowrap;
}
.table-cell-actions .btn-action {
    transition: var(--transition);
}
.table-cell-actions .action-menu { display: none; }
@media (max-width: 576px) {
    .table-cell-actions .btn-action:not(.action-menu) { display: none; }
    .table-cell-actions .action-menu { display: inline-flex; }
    .table-cell-actions.menu-open .btn-action:not(.action-menu) {
        display: inline-flex;
        position: absolute;
        top: 100%;
        right: 0;
        flex-direction: column;
        background: var(--card-bg);
        padding: 5px;
        border: 1px solid var(--light-color);
        border-radius: var(--border-radius);
        box-shadow: var(--box-shadow);
        z-index: 100;
    }
}

/* generic dropdown/popover */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--light-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    min-width: 150px;
    padding: 10px;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.dropdown.open .dropdown-content {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* more button */
.btn-action.action-menu {
    background: rgba(0,0,0,0.05);
    color: var(--primary-color);
}

@media (max-width: 576px) {
    .stats-grid--4 {
        grid-template-columns: 1fr;
    }

    .stat-card:not(.stat-card--compact) {
        flex-direction: column;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .search-box {
        max-width: 100%;
    }
}

/* ====== التحميل ====== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--muted-surface);
    border-top: 3px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ====== شريط التقدم ====== */
.progress {
    height: 8px;
    background: var(--divider);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--secondary-color);
    transition: width 0.3s ease;
}

/* ====== التفاصيل ====== */
.details-list {
    list-style: none;
}

.details-list li {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid var(--divider);
}

.details-list li:last-child {
    border-bottom: none;
}

.details-list .label {
    color: var(--text-muted);
    font-weight: 500;
}

.details-list .value {
    color: var(--text-strong);
    font-weight: 600;
}

/* ====== معلومات الوحدة ====== */
.unit-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.info-item {
    background: var(--muted-surface);
    padding: 20px;
    border-radius: var(--border-radius);
}

.info-item i {
    font-size: 24px;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.info-item h6 {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.info-item p {
    color: var(--text-strong);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

/* ====== الفاتورة ====== */
.invoice-header {
    text-align: center;
    padding: 30px;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 30px;
}

.invoice-header h2 {
    color: var(--text-strong);
    margin-bottom: 10px;
}

.invoice-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.invoice-table {
    width: 100%;
    margin-bottom: 30px;
}

.invoice-table th,
.invoice-table td {
    padding: 15px;
    border: 1px solid var(--divider);
    text-align: right;
}

.invoice-table th {
    background: var(--muted-surface);
}

.invoice-total {
    text-align: left;
    margin-top: 30px;
}

.invoice-total table {
    display: inline-block;
}

.invoice-total td {
    padding: 10px 20px;
}

.invoice-total .total-row {
    font-size: 18px;
    font-weight: 700;
    background: var(--primary-color);
    color: white;
}

/* ====== لوحة المالك ====== */
.owner-dashboard {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 40px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
}

.owner-dashboard h2 {
    margin-bottom: 10px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 30px;
}

.quick-action {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    color: white;
    text-decoration: none;
    transition: var(--transition);
}

.quick-action:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-3px);
}

.quick-action i {
    font-size: 30px;
    margin-bottom: 10px;
    display: block;
}

/* ====== الشارات ====== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-paid { background: rgba(39, 174, 96, 0.1); color: var(--success-color); }
.status-paid::before { background: var(--success-color); }

.status-unpaid { background: rgba(231, 76, 60, 0.1); color: var(--danger-color); }
.status-unpaid::before { background: var(--danger-color); }

.status-partial { background: rgba(243, 156, 18, 0.1); color: var(--warning-color); }
.status-partial::before { background: var(--warning-color); }

.status-overdue { background: rgba(108, 117, 125, 0.06); color: var(--text-muted); }
.status-overdue::before { background: #6c757d; }

/* ====== إضافات ====== */
/* Additional status indicator styles remain above; empty-state rules defined earlier. */

.timeline {
    position: relative;
    padding-right: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--divider);
}

.timeline-item {
    position: relative;
    padding-bottom: 25px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    right: -26px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--secondary-color);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--secondary-color);
}

.timeline-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.timeline-content {
    background: var(--muted-surface);
    padding: 15px;
    border-radius: var(--border-radius);
}

/* ====== الأيقونات ====== */
.icon-box {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* ====== الملخص المالي ====== */
.financial-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    text-align: center;
}

.financial-item {
    padding: 20px;
    border-radius: var(--border-radius);
}

.financial-item.income { background: rgba(39, 174, 96, 0.1); }
.financial-item.expense { background: rgba(231, 76, 60, 0.1); }
.financial-item.balance { background: rgba(52, 152, 219, 0.1); }

.financial-item h4 {
    font-size: 24px;
    margin-bottom: 5px;
}

.financial-item.income h4 { color: var(--success-color); }
.financial-item.expense h4 { color: var(--danger-color); }
.financial-item.balance h4 { color: var(--secondary-color); }

.financial-item p {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}
/* تحسينات إضافية للجوال */
@media (max-width: 768px) {
    .owner-dashboard {
        padding: 20px;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .quick-action {
        padding: 15px;
    }
    
    .quick-action i {
        font-size: 24px;
    }
    
    .quick-action span {
        font-size: 14px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .stat-details h3 {
        font-size: 20px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .card-header .btn {
        width: 100%;
    }
    
    .table th, 
    .table td {
        padding: 10px;
        font-size: 13px;
    }
    
    .btn-action {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 10px;
    }
    
    .header-left, .header-right {
        width: 100%;
        justify-content: center;
    }
    
    .user-profile {
        margin: 0 10px;
    }
    
    #notificationsPanel {
        width: 95% !important;
        left: 2.5% !important;
        max-height: 80vh;
    }
}

/* ====== Modern UI Enhancements v2 ====== */
.header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-title h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-strong);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-brand);
    color: #fff;
    font-size: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
}

.btn-primary {
    background: var(--gradient-brand);
    border: none;
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

/* Auth / Login */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse 60% 50% at 50% 0%, rgba(37, 99, 235, 0.15), transparent),
        radial-gradient(ellipse 40% 40% at 100% 100%, rgba(139, 92, 246, 0.1), transparent),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 960px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--box-shadow-lg);
    border: 1px solid var(--border);
    background: var(--surface);
}

.auth-hero {
    background: var(--gradient-sidebar);
    padding: 48px 36px;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.auth-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(96, 165, 250, 0.2), transparent 50%);
}

.auth-hero > * { position: relative; z-index: 1; }

.auth-hero-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    border-radius: 20px;
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.4);
}

.auth-hero h1 {
    font-size: 1.5rem;
    color: #f8fafc;
    margin-bottom: 12px;
}

.auth-hero p {
    color: rgba(226, 232, 240, 0.8);
    font-size: 0.95rem;
    line-height: 1.7;
}

.auth-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 32px;
}

.auth-stat .num {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
}

.auth-stat .lbl {
    font-size: 0.8rem;
    color: rgba(226, 232, 240, 0.65);
}

.auth-form-wrap {
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-form-wrap h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.auth-form-wrap .subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
}

.auth-theme-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-strong);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.auth-theme-btn:hover {
    transform: scale(1.05);
}

/* Owner dashboard */
.owner-dashboard {
    background: var(--gradient-brand);
    border-radius: var(--border-radius-lg);
    padding: 32px;
    color: #fff;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}

.owner-dashboard::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 60%;
    height: 200%;
    background: rgba(255, 255, 255, 0.06);
    transform: rotate(15deg);
    pointer-events: none;
}

.owner-dashboard h2 {
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.owner-dashboard p {
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 20px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border-radius: var(--border-radius);
    color: #fff;
    text-decoration: none;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.quick-action:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    color: #fff;
}

.quick-action i { font-size: 22px; }
.quick-action span { font-size: 13px; font-weight: 600; }

/* Notifications panel */
.notifications-panel {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    left: 20px;
    width: min(400px, calc(100vw - 40px));
    max-height: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-lg);
    z-index: 1100;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.notifications-panel[hidden] { display: none !important; }

.notifications-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notifications-panel-header h6 {
    margin: 0;
    font-size: 0.95rem;
}

.notifications-panel-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

/* ─── نظام التنبيهات المحسّن ─── */
.notif-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.notif-card {
    display: flex;
    gap: 14px;
    padding: 16px;
    border-radius: var(--border-radius-lg);
    background: var(--muted-surface);
    border: 1px solid var(--border);
    border-right: 4px solid var(--notif-color, var(--brand-primary));
    transition: var(--transition);
}

.notif-card:hover {
    border-color: var(--notif-color, var(--brand-primary));
    box-shadow: var(--box-shadow);
}

.notif-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--notif-color) 18%, transparent);
    color: var(--notif-color);
    font-size: 1.1rem;
}

.notif-card-body { flex: 1; min-width: 0; }

.notif-card-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.notif-card-header strong {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
}

.notif-card-message {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.notif-card-meta {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.85;
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    margin-bottom: 8px;
    border-radius: var(--border-radius);
    background: var(--muted-surface);
    border: 1px solid var(--border);
    border-right: 4px solid var(--notif-color, var(--brand-primary));
}

.notification-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.notification-item-header strong {
    flex: 1;
    font-size: 0.9rem;
}

.notification-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--notif-color) 18%, transparent);
    color: var(--notif-color);
}

.notification-item-content { flex: 1; min-width: 0; }

.notification-item-message {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.notification-item-meta {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notif-type-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--notif-color, #64748b) 15%, transparent);
    color: var(--notif-color, var(--text-muted));
}

.notif-type-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--notif-color) 18%, transparent);
    color: var(--notif-color);
    flex-shrink: 0;
}

.notif-row-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.notif-row-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.notif-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.notif-template-card {
    padding: 18px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border);
    background: var(--muted-surface);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition);
}

.notif-template-card:hover {
    border-color: var(--tpl-accent);
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

.notif-template-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--tpl-accent);
    background: color-mix(in srgb, var(--tpl-accent) 15%, transparent);
}

.notif-template-card h6 {
    margin: 0;
    font-size: 0.95rem;
}

.notif-template-card p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex: 1;
    line-height: 1.5;
}

.notif-template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.notif-template-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.notif-template-actions .btn { flex: 1; }

.page-title--with-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.notif-tone--danger { --notif-color: #ef4444; }
.notif-tone--warning { --notif-color: #f59e0b; }
.notif-tone--info { --notif-color: #3b82f6; }
.notif-tone--success { --notif-color: #22c55e; }
.notif-tone--purple { --notif-color: #8b5cf6; }
.notif-tone--water { --notif-color: #0ea5e9; }
.notif-tone--electric { --notif-color: #eab308; }
.notif-tone--dues { --notif-color: #f97316; }
.notif-tone--invoice { --notif-color: #06b6d4; }
.notif-tone--secondary { --notif-color: #64748b; }

a.header-icon {
    text-decoration: none;
    color: inherit;
}

a.header-icon:hover {
    color: var(--brand-primary);
}

.wa-template-preview {
    background: var(--muted-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    direction: rtl;
    margin: 8px 0;
}

.wa-console-guide h6 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--brand-primary);
}

.wa-template-preview--copy {
    border-right: 4px solid #25d366;
}

.wa-console-guide ol {
    padding-right: 1.25rem;
    line-height: 1.7;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--muted-surface);
    color: var(--text-strong);
}

.page-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-icon {
    border-radius: 14px;
}

.menu-item a {
    border-radius: 0 8px 8px 0;
    margin: 2px 12px 2px 0;
}

.menu-item.active a {
    background: rgba(96, 165, 250, 0.15);
    border-right-color: var(--brand-secondary);
    color: #fff;
}

@media (max-width: 768px) {
    .auth-card {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        padding: 32px 24px;
    }

    .auth-form-wrap {
        padding: 32px 24px;
    }

    .auth-stats {
        gap: 20px;
    }

    .header {
        padding: 0 16px;
        height: auto;
        min-height: var(--header-height);
        flex-wrap: wrap;
        gap: 12px;
    }

    .user-info { display: none; }

    .content {
        padding: 16px;
    }
}

.system-copyright-float {
    position: fixed;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    z-index: 999;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.4;
    color: rgba(148, 163, 184, 0.55);
    background: rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.12);
    pointer-events: none;
    user-select: none;
    opacity: 0.65;
}

@media (max-width: 768px) {
    .system-copyright-float {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .owner-portal .system-copyright-float {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
}

/* Admin live alerts */
.admin-alerts-panel {
    position: fixed;
    top: 64px;
    left: 24px;
    width: min(380px, calc(100vw - 32px));
    max-height: 70vh;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
    z-index: 1200;
    overflow: hidden;
}
.admin-alerts-panel[hidden] { display: none !important; }
.admin-alerts-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.admin-alerts-panel-body {
    max-height: 55vh;
    overflow-y: auto;
    padding: 8px;
}
.admin-alert-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    margin-bottom: 6px;
    border: 1px solid transparent;
}
.admin-alert-item:hover {
    background: rgba(37, 99, 235, 0.06);
    border-color: rgba(37, 99, 235, 0.15);
}
.admin-alert-empty { padding: 16px; text-align: center; }
.admin-toast-host {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(360px, calc(100vw - 32px));
}
.admin-toast {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    background: #0f172a;
    color: #f8fafc;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .25s, transform .25s;
}
.admin-toast.show { opacity: 1; transform: translateY(0); }
.admin-alert-tone--warning .admin-toast,
.admin-toast.admin-alert-tone--warning { border-right: 4px solid #f59e0b; }
.admin-toast.admin-alert-tone--info { border-right: 4px solid #3b82f6; }
.admin-toast.admin-alert-tone--danger { border-right: 4px solid #ef4444; }

/* Chat bubbles — owner / tenant / admin portals */
.chat-messages {
    max-height: 55vh;
    overflow-y: auto;
    padding: .25rem 0;
}
.chat-row {
    margin-bottom: .85rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.chat-row.is-mine {
    align-items: flex-end;
    text-align: left;
}
.chat-meta {
    opacity: .8;
    font-size: .8rem;
    color: var(--text-muted, #64748b);
    margin-bottom: .2rem;
}
.chat-bubble {
    display: inline-block;
    max-width: min(85%, 520px);
    padding: .65rem .85rem;
    border-radius: 12px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-bubble-mine {
    background: #e3f2fd;
    color: #0f172a;
}
.chat-bubble-other {
    background: #f1f5f9;
    color: #0f172a;
}
.owner-portal .chat-bubble-mine,
.tenant-portal .chat-bubble-mine {
    background: #e8f5e9;
    color: #0f172a;
}
[data-theme="dark"] .chat-meta {
    color: #94a3b8;
}
[data-theme="dark"] .chat-bubble-mine {
    background: #1e3a5f;
    color: #e2e8f0;
}
[data-theme="dark"] .chat-bubble-other {
    background: #334155;
    color: #f1f5f9;
}
[data-theme="dark"] .owner-portal .chat-bubble-mine,
[data-theme="dark"] .tenant-portal .chat-bubble-mine {
    background: #14532d;
    color: #ecfdf5;
}
[data-theme="dark"] .chat-messages .text-muted {
    color: #94a3b8 !important;
}
[data-theme="dark"] .chat-panel .card-footer {
    background: var(--surface, #1e293b);
    border-color: var(--border, #334155);
}
[data-theme="dark"] .chat-panel .form-control {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #475569;
}
[data-theme="dark"] .chat-panel .form-control::placeholder {
    color: #64748b;
}