:root {
    /* Color Tokens */
    --bg-base: #020617;
    --bg-surface: rgba(15, 23, 42, 0.6);
    --bg-surface-hover: rgba(30, 41, 59, 0.8);
    --bg-glass: rgba(30, 41, 59, 0.4);

    --border-glass: rgba(255, 255, 255, 0.05);
    --border-light: rgba(51, 65, 85, 0.5);
    --border-focus: rgba(59, 130, 246, 0.5);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.3);

    --gold: #fbbf24;
    --gold-dim: #b45309;

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #8b5cf6;
    --info-bg: rgba(139, 92, 246, 0.15);

    /* Radii & Shadows */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--primary-glow);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;

    /* Layout */
    --sidebar-width: 280px;
}

body {
    background: var(--bg-base);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    margin: 0;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6,
.brand,
.modal-title {
    font-family: 'Outfit', sans-serif;
    margin: 0;
}

/* --- Global Modern Scrollbars --- */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: var(--radius-md);
}

*::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.4);
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.8);
    border: 2px solid transparent;
    background-clip: content-box;
}

/* --- RTL Support (Arabic) --- */
[dir="rtl"] {
    font-family: 'Tajawal', sans-serif;
}

[dir="rtl"] .stat-value {
    letter-spacing: 0;
}

[dir="rtl"] .nav-item,
[dir="rtl"] .header {
    flex-direction: row;
}

/* --- Utility Classes (Replacing Inline Styles) --- */
.text-primary {
    color: var(--primary) !important;
}

.text-gold {
    color: var(--gold) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-white {
    color: var(--text-main) !important;
}

.font-bold {
    font-weight: 700 !important;
}

.font-semibold {
    font-weight: 600 !important;
}

.text-sm {
    font-size: 0.85rem !important;
}

.text-xs {
    font-size: 0.75rem !important;
}

.text-lg {
    font-size: 1.25rem !important;
}

.text-xl {
    font-size: 1.8rem !important;
}

.mb-xs {
    margin-bottom: var(--space-xs) !important;
}

.mb-sm {
    margin-bottom: var(--space-sm) !important;
}

.mb-md {
    margin-bottom: var(--space-md) !important;
}

.mb-lg {
    margin-bottom: var(--space-lg) !important;
}

.mt-xs {
    margin-top: var(--space-xs) !important;
}

.mt-sm {
    margin-top: var(--space-sm) !important;
}

.mt-md {
    margin-top: var(--space-md) !important;
}

.mt-auto {
    margin-top: auto !important;
}

.ml-sm {
    margin-inline-start: var(--space-sm) !important;
}

.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-xs {
    gap: var(--space-xs);
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.gap-lg {
    gap: var(--space-lg);
}

.w-full {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.nowrap {
    white-space: nowrap;
}

.p-md {
    padding: var(--space-md);
}

.p-lg {
    padding: var(--space-lg);
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border-inline-end: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: var(--space-lg) var(--space-md);
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 1000;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    body.rtl .sidebar {
        transform: translateX(100%);
    }

    body.rtl .sidebar.open {
        transform: translateX(0);
    }
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    margin-bottom: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.5px;
}

.nav-category {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 25px 0 10px 0;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-weight: 500;
    margin-bottom: 5px;
}

.nav-item:hover,
.nav-item.active {
    background: var(--primary-glow);
    color: white;
    box-shadow: var(--shadow-glow);
}

.nav-item.active {
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* --- Mobile Menu Button --- */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .header>div.flex {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

/* --- Main Content --- */
.main-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: var(--space-xl);
    position: relative;
    width: 100%;
}

@media (max-width: 768px) {
    .main-content {
        padding: var(--space-md);
    }
}

/* --- Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
}

/* --- Buttons --- */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 20px var(--primary-glow);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', sans-serif;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', sans-serif;
}

.btn-danger:hover {
    transform: translateY(-2px);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    margin: 0 2px;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-icon.danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-icon.info {
    background: var(--info);
    color: white;
    border-color: var(--info);
}

/* --- Added Utilities for Consolidating Inline Styles --- */
.action-bar {
    display: flex;
    gap: var(--space-sm);
    margin-top: auto;
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

.btn-action {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
    cursor: pointer;
    text-align: center;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', sans-serif;
}

.btn-action:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.btn-del:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.invite-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    border: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.invite-link {
    font-family: monospace;
    color: var(--info);
    font-size: 0.85rem;
    background: transparent;
    border: none;
    width: 100%;
    margin: 5px 0;
}

/* --- Inputs & Forms --- */
.input-dark {
    width: 100%;
    padding: 12px 16px;
    background: #1e293b;
    border: 1px solid var(--border-light);
    color: white;
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-dark:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-dark::placeholder {
    color: #64748b;
}

.input-group {
    display: flex;
    gap: var(--space-sm);
}

.input-curr {
    width: 80px;
    flex-shrink: 0;
    background: #0f172a;
    border: 1px solid var(--border-light);
    color: var(--gold);
    border-radius: var(--radius-sm);
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: #cbd5e1;
    font-weight: 500;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
}

/* --- Multi-purpose Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.stat-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 15px 0 5px 0;
    color: white;
    letter-spacing: -1px;
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-lg);
}

@media (max-width: 1000px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

.content-card {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    min-height: 300px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-glass);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.view-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Status Badges */
.badge {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    text-align: center;
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* --- Global Unified Excel Table --- */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    margin-bottom: var(--space-lg);
}

.excel-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1400px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
}

.excel-table th {
    border: 1px solid var(--border-light);
    padding: 14px 12px;
    text-align: center;
    color: white;
    background: #0f172a;
    font-weight: 600;
}

.excel-table td {
    border: 1px solid rgba(51, 65, 85, 0.3);
    padding: 12px;
    color: #cbd5e1;
    text-align: center;
    background: rgba(30, 41, 59, 0.2);
    transition: background-color 0.2s ease;
}

.excel-table tr:hover td {
    background: rgba(59, 130, 246, 0.08);
    color: white;
}

.th-sn {
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

.th-cost {
    background: #1e3a8a !important;
    color: #93c5fd !important;
}

.th-status {
    background: #78350f !important;
    color: #fcd34d !important;
}

.th-expense {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
}

.row-total td {
    background: var(--success-bg) !important;
    color: var(--success) !important;
    font-weight: bold;
    border-top: 2px solid rgba(16, 185, 129, 0.4) !important;
}

/* Sub-tables (like recent holdings in dashboard) */
.premium-table {
    width: 100%;
    border-collapse: collapse;
}

.premium-table td {
    padding: 16px 0;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-size: 0.95rem;
}

.premium-table tr:last-child td {
    border-bottom: none;
}

.premium-table tr:hover td {
    color: white;
}

/* --- Modals Component System --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.85);
    z-index: 2000;
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 420px;
    background: #0f172a;
    border: 1px solid var(--border-glass);
    padding: 40px;
    border-radius: var(--radius-lg);
    position: relative;
    box-shadow: var(--shadow-md);
    margin: auto;
}

.modal-content.large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.modal-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* --- Misc Helper Components --- */
.share-box {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    color: var(--success);
    word-break: break-all;
}

.chk-asset {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.hidden-value {
    filter: blur(5px);
    opacity: 0.5;
    user-select: none;
    cursor: not-allowed;
}

.map-picker {
    height: 300px;
    width: 100%;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-light);
    z-index: 1;
}

.error-box {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: var(--space-md);
    font-size: 0.9rem;
}

/* --- Toast Notification System --- */
#toast-container {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    min-width: 250px;
    max-width: 350px;
    padding: 16px var(--space-lg);
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-inline-start: 4px solid var(--primary);
    box-shadow: var(--shadow-md);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    border-inline-start-color: var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error {
    border-inline-start-color: var(--danger);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-info {
    border-inline-start-color: var(--info);
}

.toast-info .toast-icon {
    color: var(--info);
}

.toast-close {
    margin-inline-start: auto;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.toast-close:hover {
    color: white;
}

/* --- Leaflet Dark Theme Overrides --- */
.leaflet-control-geocoder {
    background-color: var(--bg-surface) !important;
    border: 1px solid var(--border-light) !important;
    color: white !important;
    backdrop-filter: blur(10px);
}

.leaflet-control-geocoder-form input {
    background-color: transparent !important;
    color: white !important;
}

.leaflet-control-geocoder-form input::placeholder {
    color: #94a3b8 !important;
}

.leaflet-control-geocoder-icon {
    background-color: transparent !important;
    filter: invert(1);
}

.leaflet-control-geocoder-alternatives {
    background-color: var(--bg-surface) !important;
    border: 1px solid var(--border-light) !important;
    backdrop-filter: blur(10px);
}

.leaflet-control-geocoder-alternatives li {
    color: white !important;
    border-bottom: 1px solid var(--border-glass) !important;
}

.leaflet-control-geocoder-alternatives li a,
.leaflet-control-geocoder-alternatives li a:hover {
    color: white !important;
    background-color: transparent !important;
}

.leaflet-control-geocoder-alternatives li:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* --- Empty States --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl) var(--space-md);
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-light);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.7;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin-bottom: var(--space-xs);
}

.empty-state-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 300px;
}