/* === CSS Custom Properties === */
:root {
    --bg-body: #f0f2f5;
    --bg-card: #fff;
    --bg-input: #fff;
    --bg-th: #fafafa;
    --bg-hover: #f8f9ff;
    --bg-upload-hover: #f0f9ff;
    --bg-progress: #e0e0e0;
    --text-primary: #1a1a2e;
    --text-secondary: #888;
    --text-label: #666;
    --text-form-label: #555;
    --border-color: #eee;
    --border-input: #ddd;
    --border-upload: #ccc;
    --accent: #4fc3f7;
    --accent-hover: #29b6f6;
    --credit: #2e7d32;
    --debit: #c62828;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-modal: 0 8px 32px rgba(0,0,0,0.2);
    --overlay: rgba(0,0,0,0.5);
    --btn-secondary-bg: #e0e0e0;
    --btn-secondary-text: #333;
    --btn-danger-bg: #ffcdd2;
    --btn-danger-text: #c62828;
    --tag-bg: #e3f2fd;
    --tag-text: #1565c0;
    --tag-ar-bg: #fff3e0;
    --tag-ar-text: #e65100;
    --badge-credit-bg: #e8f5e9;
    --badge-credit-text: #2e7d32;
    --badge-debit-bg: #ffebee;
    --badge-debit-text: #c62828;
    --badge-merchant-bg: #e8eaf6;
    --badge-merchant-text: #3f51b5;
    --badge-reassigned-bg: #fff3e0;
    --badge-reassigned-text: #e65100;
    --sortable-hover: #eef;
    --filter-tab-bg: #fff;
    --toast-shadow: 0 4px 12px rgba(0,0,0,0.15);
    --focus-ring: rgba(79,195,247,0.2);
    /* Sidebar stays dark in both themes */
    --sidebar-bg: #1a1a2e;
    --sidebar-text: #e0e0e0;
    --sidebar-border: #2d2d44;
    --sidebar-hover: #2d2d44;
    --sidebar-heading: #fff;
    --nav-text: #a0a0b8;
}

[data-theme="dark"] {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --bg-input: #2a2a2a;
    --bg-th: #252525;
    --bg-hover: #252530;
    --bg-upload-hover: #1a2030;
    --bg-progress: #333;
    --text-primary: #e0e0e0;
    --text-secondary: #999;
    --text-label: #aaa;
    --text-form-label: #bbb;
    --border-color: #333;
    --border-input: #444;
    --border-upload: #444;
    --credit: #66bb6a;
    --debit: #ef5350;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-modal: 0 8px 32px rgba(0,0,0,0.5);
    --overlay: rgba(0,0,0,0.7);
    --btn-secondary-bg: #333;
    --btn-secondary-text: #ccc;
    --btn-danger-bg: #4a1a1a;
    --btn-danger-text: #ef5350;
    --tag-bg: #1a3050;
    --tag-text: #64b5f6;
    --tag-ar-bg: #3e2a10;
    --tag-ar-text: #ffb74d;
    --badge-credit-bg: #1a3a1a;
    --badge-credit-text: #66bb6a;
    --badge-debit-bg: #3a1a1a;
    --badge-debit-text: #ef5350;
    --badge-merchant-bg: #1a1a3a;
    --badge-merchant-text: #7986cb;
    --badge-reassigned-bg: #3e2a10;
    --badge-reassigned-text: #ffb74d;
    --sortable-hover: #252535;
    --filter-tab-bg: #1e1e1e;
    --toast-shadow: 0 4px 12px rgba(0,0,0,0.4);
    --focus-ring: rgba(79,195,247,0.3);
    --sidebar-bg: #0d0d1a;
    --sidebar-border: #1a1a2e;
    --sidebar-hover: #1a1a2e;
}

/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Arial, 'Noto Sans Arabic', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-header h2 {
    font-size: 1.3rem;
    color: var(--sidebar-heading);
    font-weight: 600;
}
.sidebar-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}
.nav-links {
    list-style: none;
    padding: 12px 0;
}
.nav-links li a {
    display: block;
    padding: 12px 20px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.nav-links li a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.nav-links li a.active {
    background: var(--sidebar-hover);
    color: var(--accent);
    border-left-color: var(--accent);
}

.nav-badge {
    display: inline-block;
    background: #f44336;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
    line-height: 1.4;
}

/* Content */
.content {
    margin-left: 220px;
    padding: 28px 32px;
    flex: 1;
    min-width: 0;
}
.content h1 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.card-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.card-value.credit { color: var(--credit); }
.card-value.debit { color: var(--debit); }

/* Section */
.section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Tables */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
th {
    font-weight: 600;
    color: var(--text-label);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--bg-th);
    position: sticky;
    top: 0;
}
tr:hover td { background: var(--bg-hover); }
.amount-credit { color: var(--credit); font-weight: 500; }
.amount-debit { color: var(--debit); font-weight: 500; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    gap: 6px;
}
.btn-primary {
    background: var(--accent);
    color: #1a1a2e;
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
}
.btn-secondary:hover { opacity: 0.8; }
.btn-danger {
    background: var(--btn-danger-bg);
    color: var(--btn-danger-text);
}
.btn-danger:hover { opacity: 0.8; }
.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}
.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-form-label);
    margin-bottom: 4px;
}
input, select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

/* Filters bar */
.filters-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}
.filters-bar .form-group {
    margin-bottom: 0;
    min-width: 140px;
}
.filters-bar input, .filters-bar select {
    width: auto;
    min-width: 140px;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    padding: 16px 0 0;
}
.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border-input);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}
.pagination button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}
.pagination .page-info {
    padding: 0 12px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--tag-bg);
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--tag-text);
    margin: 2px;
}
.tag .tag-remove {
    cursor: pointer;
    font-weight: bold;
    color: var(--debit);
    margin-left: 4px;
}
.tag-ar {
    background: var(--tag-ar-bg);
    color: var(--tag-ar-text);
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border-upload);
    border-radius: 12px;
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 24px;
}
.upload-area:hover, .upload-area.drag-over {
    border-color: var(--accent);
    background: var(--bg-upload-hover);
}
.upload-area p {
    color: var(--text-secondary);
    margin-top: 8px;
}
.upload-area input[type="file"] {
    display: none;
}

/* Progress */
.progress-bar {
    height: 4px;
    background: var(--bg-progress);
    border-radius: 2px;
    overflow: hidden;
    margin: 12px 0;
}
.progress-bar .fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

/* Member cards */
.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.member-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 18px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.member-card:hover { box-shadow: var(--shadow-hover); }
.member-card .name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.member-card .family {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
.member-card .stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
@media (max-width: 900px) {
    .chart-row { grid-template-columns: 1fr; }
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: var(--toast-shadow);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }
.toast.info { background: #1565c0; }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-modal);
    color: var(--text-primary);
}
.modal h3 {
    margin-bottom: 16px;
    font-size: 1.2rem;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-credit { background: var(--badge-credit-bg); color: var(--badge-credit-text); }
.badge-debit { background: var(--badge-debit-bg); color: var(--badge-debit-text); }
.badge-reassigned {
    background: var(--badge-reassigned-bg);
    color: var(--badge-reassigned-text);
    font-size: 0.7rem;
    margin-left: 4px;
}

/* Utility */
th.sortable {
    cursor: pointer;
    user-select: none;
}
th.sortable:hover {
    background: var(--sortable-hover);
}

.text-muted { color: var(--text-secondary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.hidden { display: none !important; }

/* Status dots */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-completed { background: #4caf50; }
.status-processing { background: #ff9800; }
.status-error { background: #f44336; }
.status-pending { background: #9e9e9e; }

/* Badge merchant */
.badge-merchant { background: var(--badge-merchant-bg); color: var(--badge-merchant-text); font-size: 0.7rem; margin-left: 4px; }

/* Sidebar account section */
.sidebar-account {
    margin-top: auto;
    border-top: 1px solid var(--sidebar-border);
    padding: 14px 20px 10px;
}
.sidebar-account-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.sidebar-account-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    text-transform: uppercase;
}
.sidebar-account-detail {
    min-width: 0;
    flex: 1;
}
.sidebar-account-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-account-role {
    font-size: 0.7rem;
    color: var(--nav-text);
    text-transform: capitalize;
}
.sidebar-account-actions {
    display: flex;
    gap: 6px;
}
.sidebar-action-btn {
    flex: 1;
    padding: 5px 0;
    border: 1px solid var(--sidebar-border);
    background: transparent;
    color: var(--nav-text);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s;
    text-align: center;
}
.sidebar-action-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}
.sidebar-action-logout:hover {
    border-color: #ef5350;
    color: #ef5350;
}

/* Language & Theme toggle */
.sidebar-bottom {
    border-top: 1px solid var(--sidebar-border);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.lang-toggle {
    display: flex;
    gap: 8px;
}
.lang-btn {
    padding: 4px 14px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--nav-text);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}
.lang-btn.active {
    background: var(--accent);
    color: #1a1a2e;
    font-weight: 600;
}
.theme-btn {
    padding: 4px 10px;
    border: 1px solid var(--sidebar-border);
    background: transparent;
    color: var(--nav-text);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.15s;
}
.theme-btn:hover {
    background: var(--sidebar-hover);
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}
.filter-tab {
    padding: 6px 16px;
    border: 1px solid var(--border-input);
    background: var(--filter-tab-bg);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}
.filter-tab.active {
    background: var(--accent);
    color: #1a1a2e;
    border-color: var(--accent);
    font-weight: 600;
}

/* Accent border section */
.section-accent { border-left: 4px solid #ff9800; }

/* Sidebar search */
.sidebar-search {
    padding: 8px 20px 4px;
}
.sidebar-search input {
    background: var(--sidebar-hover);
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    width: 100%;
}
.sidebar-search input::placeholder {
    color: var(--nav-text);
}
.sidebar-search input:focus {
    border-color: var(--accent);
    outline: none;
}

/* Search results */
.search-result-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s;
}
.search-result-item:hover {
    background: var(--bg-hover);
}
.search-result-item:last-child {
    border-bottom: none;
}

/* Goal progress bars */
.goal-bar {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.goal-bar .goal-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.goal-bar .goal-track {
    height: 12px;
    background: var(--bg-progress);
    border-radius: 6px;
    overflow: hidden;
}
.goal-bar .goal-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s;
    min-width: 2px;
}
.goal-fill-green { background: #4caf50; }
.goal-fill-yellow { background: #ff9800; }
.goal-fill-red { background: #f44336; }

/* Alert box */
.alert-box {
    background: var(--badge-reassigned-bg);
    color: var(--badge-reassigned-text);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-warning {
    background: var(--badge-reassigned-bg);
    color: var(--badge-reassigned-text);
}
.alert-box-danger {
    background: var(--badge-debit-bg);
    color: var(--badge-debit-text);
}

/* WhatsApp summary preview */
.summary-preview {
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 8px;
    padding: 16px;
    font-family: monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    color: var(--text-primary);
}

/* Goal card grid */
.goal-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.summary-grid {
    grid-template-columns: repeat(4, 1fr);
}
.goal-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 280px;
}
.goal-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}
.goal-card-body {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}
.goal-circle-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}
.goal-circle-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 4px;
}
.goal-ring {
    display: block;
}
.goal-amounts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.goal-amount-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}
.goal-card-ytd {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    margin-top: auto;
}
.goal-ytd-body {
    display: flex;
    align-items: center;
    gap: 12px;
}
.goal-track {
    height: 12px;
    background: var(--bg-progress);
    border-radius: 6px;
    overflow: hidden;
}
.goal-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s;
    min-width: 2px;
}

/* Hamburger button - hidden on desktop */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--sidebar-bg);
    border: none;
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
}
.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.2s;
}

/* Sidebar overlay - hidden on desktop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
    }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.visible {
        display: block;
    }
    .content {
        margin-left: 0 !important;
        padding: 56px 16px 16px !important;
    }
    .modal {
        min-width: auto !important;
        width: calc(100vw - 32px) !important;
        max-width: 600px;
        margin: 16px;
    }
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 10px;
    }
    .goal-card-grid {
        grid-template-columns: 1fr !important;
    }
    .summary-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    table { font-size: 0.8rem; }
    th, td { padding: 8px 6px; }
    .flex-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
    .content h1 { font-size: 1.3rem; }
    .btn-group { flex-wrap: wrap; }
    .chart-container { height: 220px; }
    .chart-row { grid-template-columns: 1fr !important; }
}

/* RTL mobile overrides */
@media (max-width: 768px) {
    body.rtl .hamburger-btn {
        left: auto;
        right: 12px;
    }
    body.rtl .sidebar {
        transform: translateX(100%);
    }
    body.rtl .sidebar.open {
        transform: translateX(0);
    }
    body.rtl .content {
        margin-right: 0 !important;
    }
}

/* Large screen */
@media (min-width: 1600px) {
    .content {
        max-width: 100%;
    }
}

/* === Auth pages === */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.auth-logo {
    text-align: center;
    margin-bottom: 16px;
}
.auth-logo img {
    width: 80px;
    height: 80px;
}
.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}
.auth-card .form-group {
    text-align: left;
}
.auth-btn {
    width: 100%;
    padding: 11px;
    font-size: 0.95rem;
    margin-top: 4px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    justify-content: center;
}
.auth-totp-input {
    text-align: center;
    letter-spacing: 4px;
    font-size: 1.1rem !important;
}
.auth-error {
    color: var(--debit);
    font-size: 0.8rem;
    margin-bottom: 8px;
    display: none;
}
.auth-success {
    color: var(--credit);
    font-size: 0.8rem;
    margin-bottom: 8px;
    display: none;
    background: var(--badge-credit-bg);
    padding: 10px;
    border-radius: 6px;
}
.auth-switch {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.auth-switch a:hover {
    text-decoration: underline;
}

/* === RTL Overrides === */
body.rtl { direction: rtl; }

body.rtl .sidebar {
    left: auto;
    right: 0;
}

body.rtl .content {
    margin-left: 0;
    margin-right: 220px;
}

body.rtl .nav-links li a {
    border-left: none;
    border-right: 3px solid transparent;
}
body.rtl .nav-links li a.active {
    border-left-color: transparent;
    border-right-color: var(--accent);
}

body.rtl th, body.rtl td {
    text-align: right;
}
body.rtl .text-right {
    text-align: left;
}

body.rtl .status-dot {
    margin-right: 0;
    margin-left: 6px;
}

body.rtl .tag .tag-remove {
    margin-left: 0;
    margin-right: 4px;
}

body.rtl .badge-reassigned {
    margin-left: 0;
    margin-right: 4px;
}
body.rtl .badge-merchant {
    margin-left: 0;
    margin-right: 4px;
}

body.rtl .modal-footer {
    justify-content: flex-start;
}

body.rtl #toast-container {
    right: auto;
    left: 20px;
}

body.rtl .toast {
    animation: slideInRTL 0.3s ease;
}
@keyframes slideInRTL {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

body.rtl .section-accent {
    border-left: none;
    border-right: 4px solid #ff9800;
}

/* === Print Styles === */
@media print {
    .sidebar,
    .sidebar-overlay,
    .hamburger-btn,
    #toast-container,
    .modal-overlay,
    .btn,
    .btn-group,
    .filters-bar,
    .filter-tabs,
    .pagination,
    .upload-area,
    .progress-bar,
    .sidebar-search,
    .lang-toggle,
    .theme-btn,
    .sidebar-bottom,
    .tag-remove,
    input[type="file"],
    #global-search,
    #bulk-actions {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        display: block !important;
    }
    .content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    .card, .section {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .card-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .chart-row {
        grid-template-columns: 1fr 1fr !important;
    }

    table { font-size: 0.8rem !important; }
    th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    tr { page-break-inside: avoid; }
    tr:hover td { background: transparent !important; }

    .amount-credit { color: #2e7d32 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .amount-debit { color: #c62828 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .card-value.credit { color: #2e7d32 !important; }
    .card-value.debit { color: #c62828 !important; }

    .chart-container { height: 250px !important; }
    canvas { max-width: 100% !important; }

    .goal-card {
        min-height: auto !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .goal-card-grid { grid-template-columns: repeat(2, 1fr) !important; }

    .summary-preview {
        max-height: none !important;
        overflow: visible !important;
    }

    .badge, .tag {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .alert-box {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .status-dot {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .content h1 {
        font-size: 1.4rem !important;
        border-bottom: 2px solid #333;
        padding-bottom: 8px;
        margin-bottom: 16px;
    }

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