/* Elite Club Accounting - Odoo-inspired UI */
:root {
    --primary: #714B67;
    --primary-dark: #5a3d52;
    --primary-light: #8f6b84;
    --accent: #00A09D;
    --accent-light: #e6f7f7;
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, 'Noto Sans Arabic', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    grid-column: 1;
    width: var(--sidebar-width);
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    text-align: center;
}

.sidebar-brand h2 { font-size: 1.1em; font-weight: 600; }
.sidebar-brand small { opacity: 0.7; font-size: 0.75em; }

.sidebar-nav { padding: 15px 0; }

.nav-section {
    padding: 8px 20px 4px;
    font-size: 0.7em;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 0.5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9em;
    transition: all 0.2s;
    border-inline-end: 3px solid transparent;
}

.nav-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active { background: rgba(255,255,255,0.15); border-inline-end-color: var(--accent); color: white; font-weight: 600; }
.nav-link .icon { width: 20px; text-align: center; font-size: 1.1em; }
.nav-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65em;
    font-weight: 700;
    border-radius: 9px;
    padding: 0 5px;
    margin-inline-start: 6px;
    vertical-align: middle;
}

.main-content {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
    gap: 16px;
    flex-shrink: 0;
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.topbar-title {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.topbar-company-select {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-inline-start: 12px;
}

.topbar-company-select .form-control {
    font-size: 0.85em;
    padding: 4px 8px;
    min-width: 180px;
    max-width: 280px;
}
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 0.85em; }
.topbar-user .role-badge {
    background: var(--accent-light);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.page-content {
    padding: 24px;
    width: 100%;
    max-width: 100%;
    flex: 1;
}

.page-content a:not(.btn):not(.app-tile):not(.nav-link) {
    color: var(--primary);
    text-decoration: none;
}

.page-content a:not(.btn):not(.app-tile):not(.nav-link):hover {
    text-decoration: underline;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 { font-size: 1em; font-weight: 600; margin: 0; }
.card-body { padding: 20px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    width: 100%;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-inline-end: 4px solid var(--primary);
    min-width: 0;
    overflow: hidden;
}

.stat-card.accent { border-inline-end-color: var(--accent); }
.stat-card.success { border-inline-end-color: var(--success); }
.stat-card.danger { border-inline-end-color: var(--danger); }
.stat-card.warning { border-inline-end-color: var(--warning); }

.stat-card .label { font-size: 0.8em; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value {
    font-size: clamp(1.05rem, 2.2vw, 1.45em);
    font-weight: 700;
    line-height: 1.35;
    word-break: normal;
    overflow-wrap: normal;
    overflow-x: auto;
}
/* مبالغ: دائماً LTR حتى لا ينكسر السالب أو «جنيه» في واجهة عربية */
.money {
    direction: ltr;
    unicode-bidi: isolate;
    white-space: nowrap;
    display: inline-block;
    font-variant-numeric: tabular-nums;
}
.stat-card .sub { font-size: 0.75em; color: var(--text-muted); margin-top: 4px; }
.stat-card .sub a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.stat-card .sub a:hover { text-decoration: underline; }

.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88em;
}

table.data-table th {
    background: #f8f9fa;
    padding: 12px 14px;
    text-align: right;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    border-left: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table th:last-child,
table.data-table td:last-child {
    border-left: none;
}

table.data-table tr:hover td { background: #f8f9fa; }
table.data-table .amount {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
    white-space: nowrap;
}

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

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.85em; font-weight: 600; }
.form-group .hint { font-size: 0.75em; color: var(--text-muted); margin-top: 4px; }

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9em;
    font-family: inherit;
    background: white;
}

.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(113,75,103,0.15); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-check { display: flex; align-items: center; gap: 8px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 0.8em; }
.btn-xs { padding: 3px 9px; font-size: 0.75em; border-radius: 5px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.75em; font-weight: 600; }
.badge-asset     { background: #e3f2fd; color: #1565c0; }
.badge-liability { background: #fce4ec; color: #c62828; }
.badge-equity    { background: #f3e5f5; color: #7b1fa2; }
.badge-revenue   { background: #e8f5e9; color: #2e7d32; }
.badge-expense   { background: #fff3e0; color: #e65100; }
.badge-draft     { background: #fff3cd; color: #856404; }
.badge-posted    { background: #d4edda; color: #155724; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-active    { background: #d4edda; color: #155724; }
.badge-inactive  { background: #f8d7da; color: #721c24; }
.badge-group     { background: #f3eef2; color: #714B67; font-weight: 600; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9em; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info {
    background: #eef8f7;
    border: 1px solid #b9e0dc;
    color: #1a4a46;
    padding: 12px 14px;
    border-radius: 8px;
}

.invoice-sheet-header {
    align-items: flex-start;
}
.invoice-sheet-sub {
    margin: 6px 0 0;
    color: var(--text-muted, #777);
    font-size: 0.9rem;
    font-weight: 400;
}
.invoice-header-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 14px 16px;
    margin-bottom: 20px;
}
.invoice-partner-field { grid-column: 1 / 2; }
.form-control-lg {
    min-height: 42px;
    font-size: 1.05rem;
}
.invoice-lines-panel {
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 10px;
    padding: 14px;
    background: #fafafa;
    margin-bottom: 18px;
}
.invoice-lines-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
}
.invoice-lines-panel-head h4 {
    margin: 0;
    color: var(--primary, #714B67);
}
.invoice-lines-table .inv-line-sub {
    font-weight: 600;
}
.invoice-footer-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
    margin-top: 8px;
}
.invoice-totals-box {
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.invoice-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border, #e5e5e5);
    font-size: 0.95rem;
}
.invoice-totals-row:last-child { border-bottom: 0; }
.invoice-totals-grand {
    background: var(--primary, #714B67);
    color: #fff;
    font-size: 1.05rem;
}
.invoice-form-actions { margin-top: 18px; }
.company-logo-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.company-logo-preview {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
    background: #fff;
    padding: 4px;
}
.company-logo-placeholder {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border, #ccc);
    border-radius: 8px;
    color: var(--text-muted, #888);
    font-size: 0.8rem;
}
@media (max-width: 960px) {
    .invoice-header-grid { grid-template-columns: 1fr 1fr; }
    .invoice-partner-field { grid-column: 1 / -1; }
    .invoice-footer-grid { grid-template-columns: 1fr; }
}

.journal-lines-table input, .journal-lines-table select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85em;
    width: 100%;
}

.row-editing { background: #f3eef2 !important; }

/* نافذة تأكيد داخل النظام (بدل رسائل المتصفح) */
body.app-modal-open { overflow: hidden; }
.app-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.app-modal.open { display: flex; }
.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(30, 20, 35, 0.45);
}
.app-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    animation: appModalIn 0.16s ease-out;
}
@keyframes appModalIn {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.app-modal-header {
    background: var(--primary, #714B67);
    color: #fff;
    padding: 14px 18px;
}
.app-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}
.app-modal-body {
    padding: 20px 18px;
}
.app-modal-message {
    margin: 0;
    font-size: 1rem;
    line-height: 1.7;
    color: #333;
}
.app-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border, #e5e5e5);
    background: #fafafa;
}
.journal-lines-table .line-totals { background: #f8f9fa; font-weight: 700; }
.journal-lines-table .unbalanced { color: var(--danger); }
.journal-lines-table .balanced { color: var(--success); }

/* Chart of Accounts — hierarchical tree */
.account-stats .stat-card .value { font-variant-numeric: tabular-nums; }

.account-tree { font-size: 0.9em; }
.account-tree thead th {
    font-size: 0.82em;
    letter-spacing: 0.01em;
    color: #555;
}
.account-tree tbody tr { transition: background 0.12s ease; }
.account-tree tbody tr:hover td { background: #f6f3f5; }
.account-tree .group-row td {
    font-weight: 600;
    background: #faf8fa;
    border-bottom-color: #ebe4e9;
}
.account-tree .group-row:hover td { background: #f3eef2; }
.account-tree .child-row td { font-weight: 400; }
.account-tree tr.is-collapsed { display: none; }

.account-tree .col-account { min-width: 280px; }
.account-tree .col-balance { text-align: left; white-space: nowrap; min-width: 120px; }
.account-tree .col-actions { width: 1%; white-space: nowrap; }

.account-tree .account-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-inline-start: 0;
}
.account-tree .account-cell.level-1 { padding-inline-start: 1.25rem; }
.account-tree .account-cell.level-2 { padding-inline-start: 2.5rem; }
.account-tree .account-cell.level-3 { padding-inline-start: 3.75rem; }
.account-tree .account-cell.level-4 { padding-inline-start: 5rem; }
.account-tree .account-cell.level-5 { padding-inline-start: 6.25rem; }
.account-tree .account-cell.level-6 { padding-inline-start: 7.5rem; }

.account-tree .tree-toggle {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid #d4c4d0;
    border-radius: 4px;
    background: #fff;
    color: var(--primary);
    font-size: 0.7em;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s;
}
.account-tree .tree-toggle:hover {
    background: #f3eef2;
    border-color: var(--primary);
}
.account-tree .tree-toggle[aria-expanded="false"] {
    background: #f3eef2;
}
.account-tree .tree-toggle-spacer {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: inline-block;
}

.account-tree .account-code {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--primary);
    min-width: 3.2em;
}
.account-tree .account-code a,
.account-tree .account-name a {
    color: inherit;
    text-decoration: none;
}
.account-tree .account-code a:hover,
.account-tree .account-name a:hover {
    color: var(--accent);
    text-decoration: underline;
}
.account-tree .account-name { color: var(--text); }
.account-tree .group-row .account-name { color: #3d2a38; }

.account-tree .account-actions { gap: 6px; justify-content: flex-start; }
.account-tree .account-actions .btn { opacity: 0.92; }
.account-tree tr:hover .account-actions .btn { opacity: 1; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 { color: var(--primary); text-align: center; margin-bottom: 8px; font-size: 1.4em; }
.login-box .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 0.85em; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.filters-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters-bar .form-group { margin-bottom: 0; }

@media (max-width: 768px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        transform: translateX(100%);
        box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { grid-column: 1; }
    .menu-toggle { display: block !important; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .apps-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .dashboard-panels { grid-template-columns: 1fr !important; }
    .topbar { padding: 0 16px; }
    .page-content { padding: 16px; }
    .topbar-company-select .form-control { min-width: 140px; max-width: 180px; }
}

.menu-toggle { display: none; background: none; border: none; font-size: 1.4em; cursor: pointer; color: var(--primary); }

@media print {
    .sidebar, .topbar, .filters-bar, .btn-group, .btn, .menu-toggle, .status-bar, .breadcrumbs { display: none !important; }
    .app-layout { grid-template-columns: 1fr !important; }
    .main-content { grid-column: 1 !important; }
    .page-content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* Odoo-style status bar */
.status-bar { display: flex; align-items: center; background: white; border-radius: var(--radius); padding: 12px 20px; margin-bottom: 20px; box-shadow: var(--shadow); overflow-x: auto; }
.status-step { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 20px; font-size: 0.85em; color: var(--text-muted); white-space: nowrap; }
.status-step .step-num { width: 22px; height: 22px; border-radius: 50%; background: #e9ecef; display: flex; align-items: center; justify-content: center; font-size: 0.75em; font-weight: 700; }
.status-step.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.status-step.active .step-num { background: var(--accent); color: white; }
.status-step.done { color: var(--success); }
.status-step.done .step-num { background: var(--success); color: white; }
.status-arrow { color: #ccc; margin: 0 4px; font-size: 1.2em; }

/* Breadcrumbs */
.breadcrumbs { font-size: 0.85em; margin-bottom: 16px; color: var(--text-muted); }
.breadcrumbs a { color: var(--primary); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .bc-sep { margin: 0 8px; color: #ccc; }
.breadcrumbs .bc-current { color: var(--text); font-weight: 600; }

/* Apps grid (Odoo home) */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
    width: 100%;
}

.app-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 132px;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border: 2px solid transparent;
}

.app-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    border-color: var(--accent);
    color: var(--text);
    text-decoration: none;
}

.app-tile .app-icon { font-size: 2.2em; margin-bottom: 8px; line-height: 1; }
.app-tile .app-name { font-size: 0.85em; font-weight: 600; color: var(--text); }
.app-tile .app-desc { font-size: 0.7em; color: var(--text-muted); margin-top: 4px; }

/* Dashboard */
.dashboard-welcome {
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
}

.dashboard-welcome .card-body { padding: 24px; }
.dashboard-welcome h2 { margin: 0 0 4px; font-size: 1.35em; }
.dashboard-welcome p { margin: 0; opacity: 0.85; font-size: 0.9em; }

.alert-list-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.alert-list-link:hover { background: #f8f9fa; text-decoration: none; }
.alert-list-link:last-child { border-bottom: none; }

.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Utilities */
.card-body-flush { padding: 0 !important; }
.mb-20 { margin-bottom: 20px; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted); }
.value-sm { font-size: 1.1em !important; }
.badge-spaced { margin-inline-start: 8px; }

.topbar-company-badge {
    background: var(--accent);
    color: #fff;
}

.section-title {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-light);
}

/* Report tiles */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
}

.report-tile {
    display: block;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.report-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    border-color: var(--accent);
    text-decoration: none;
    color: inherit;
}

.report-tile .report-icon {
    font-size: 2em;
    margin-bottom: 8px;
    line-height: 1;
}

.report-tile strong {
    display: block;
    font-size: 1em;
    color: var(--text);
}

.report-tile p {
    font-size: 0.85em;
    color: var(--text-muted);
    margin: 8px 0 0;
    line-height: 1.5;
}

/* Buttons hover */
.btn-accent:hover { filter: brightness(0.92); }
.btn-success:hover { filter: brightness(0.92); }
.btn-danger:hover { filter: brightness(0.92); }
.btn-outline:hover { background: #f8f9fa; border-color: var(--primary); color: var(--primary); }

/* Empty state */
.empty-state .icon { font-size: 2.5em; margin-bottom: 12px; opacity: 0.5; }

/* Login extras */
.password-field { position: relative; }
.password-field .form-control { padding-inline-start: 40px; }
.password-toggle {
    position: absolute;
    inset-inline-start: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px;
}
.login-box .btn-block { width: 100%; margin-top: 8px; }
.login-hint {
    margin-top: 16px;
    font-size: 0.8em;
    color: var(--text-muted);
    text-align: center;
}

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
    .topbar-user {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
    }
    .topbar-user .role-badge { display: none; }
    .topbar-title { font-size: 1em; }
    .report-grid { grid-template-columns: 1fr; }
}

/* ─── دليل المستخدم — تنسيق ورقة A4 ─────────────────────────── */
.help-page {
    background: #c8c8c8;
    margin: -20px -24px 0;
    padding: 20px 16px 48px;
    min-height: calc(100vh - var(--topbar-height) - 40px);
}

.help-toolbar {
    max-width: 210mm;
    margin: 0 auto 16px;
}

.help-toolbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 12px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    gap: 12px;
    flex-wrap: wrap;
}

.help-toolbar-title {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95em;
}

.help-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 210mm);
    gap: 20px;
    justify-content: center;
    align-items: start;
}

.help-nav {
    position: sticky;
    top: 72px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}

.help-nav h4 {
    font-size: 0.82em;
    color: var(--primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
}

.help-nav a {
    display: block;
    padding: 6px 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.82em;
    border-radius: 4px;
    margin-bottom: 1px;
    border-right: 2px solid transparent;
}

.help-nav a:hover {
    background: var(--accent-light);
    color: var(--primary);
    border-right-color: var(--accent);
}

/* ورقة A4 */
.help-document {
    width: 100%;
    max-width: 210mm;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12), 0 8px 32px rgba(0,0,0,0.1);
    padding: 18mm 16mm 22mm;
    min-height: 297mm;
    color: #1a1a1a;
    font-size: 11pt;
    line-height: 1.75;
}

.help-doc-header {
    text-align: center;
    border-bottom: 3px double var(--primary);
    padding-bottom: 18px;
    margin-bottom: 28px;
}

.help-doc-logo {
    font-size: 0.85em;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.help-doc-title {
    font-size: 1.55em;
    color: var(--primary);
    margin: 0 0 8px;
    font-weight: 700;
}

.help-doc-subtitle {
    font-size: 0.92em;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.help-doc-meta {
    font-size: 0.8em;
    color: #888;
    margin: 0;
}

.help-doc-footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #ccc;
    text-align: center;
    font-size: 0.82em;
    color: #666;
}

.help-doc-footer-note {
    margin-top: 4px;
    font-size: 0.9em;
}

.help-content {
    counter-reset: help-section;
}

.help-section {
    margin-bottom: 26px;
    padding-bottom: 22px;
    border-bottom: 1px solid #e4e4e4;
    page-break-inside: avoid;
}

.help-section:last-child {
    border-bottom: none;
}

.help-section h3 {
    counter-increment: help-section;
    color: var(--primary);
    font-size: 1.12em;
    font-weight: 700;
    margin: 0 0 14px;
    padding: 8px 14px 8px 0;
    border-right: 5px solid var(--primary);
    background: linear-gradient(to left, #f9f5f8, transparent);
}

.help-section h3::before {
    content: "القسم " counter(help-section) " — ";
    color: var(--accent);
    font-size: 0.88em;
}

.help-section--intro h3::before { content: ""; }

.help-subsection {
    margin: 16px 0 12px;
    padding-right: 12px;
}

.help-subsection h4 {
    color: #333;
    font-size: 1em;
    font-weight: 600;
    margin: 0 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px dotted #ccc;
}

.help-lead {
    font-size: 1.02em;
    line-height: 1.9;
    text-align: justify;
    margin: 0;
}

.help-section h4 {
    color: #333;
    font-size: 0.98em;
    font-weight: 600;
    margin: 16px 0 8px;
}

.help-section p {
    margin: 8px 0;
    text-align: justify;
}

.help-bullets,
.help-section ul:not(.help-steps) {
    list-style: disc;
    padding-right: 28px;
    margin: 10px 0;
}

.help-bullets li,
.help-section ul:not(.help-steps) li {
    margin-bottom: 7px;
    line-height: 1.8;
}

.help-section ol:not(.help-steps) {
    padding-right: 28px;
    margin: 10px 0;
}

.help-steps {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.help-steps li {
    counter-increment: step;
    padding: 10px 50px 10px 12px;
    margin-bottom: 8px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-right: 4px solid var(--accent);
    position: relative;
    line-height: 1.75;
}

.help-steps li::before {
    content: counter(step);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8em;
}

.help-tip {
    background: #eefaf9;
    border: 1px solid #b8e0de;
    border-right: 4px solid var(--accent);
    padding: 12px 16px;
    border-radius: 4px;
    margin: 14px 0;
    font-size: 0.92em;
}

.help-warning {
    background: #fffbf0;
    border: 1px solid #f0d78c;
    border-right: 4px solid var(--warning);
    padding: 12px 16px;
    border-radius: 4px;
    margin: 14px 0;
    font-size: 0.92em;
}

.help-table-wrap {
    overflow-x: auto;
    margin: 14px 0;
}

.help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88em;
}

.help-table th,
.help-table td {
    padding: 9px 11px;
    border: 1px solid #bbb;
    text-align: right;
}

.help-table th {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.help-table tr:nth-child(even) td {
    background: #f7f7f7;
}

.help-module {
    border: 1px solid #ddd;
    margin-bottom: 10px;
    page-break-inside: avoid;
}

.help-module summary {
    padding: 11px 14px;
    cursor: pointer;
    font-weight: 600;
    background: #f5f5f5;
    list-style: none;
    font-size: 0.95em;
    border-bottom: 1px solid transparent;
}

.help-module[open] summary {
    border-bottom-color: #ddd;
    background: #eee;
}

.help-module summary::-webkit-details-marker { display: none; }

.help-module summary::before {
    content: '▸ ';
    color: var(--accent);
    font-weight: bold;
}

.help-module[open] summary::before { content: '▾ '; }

.help-module .module-body {
    padding: 14px 16px;
    font-size: 0.94em;
}

.help-module .module-body ul,
.help-module .module-body ol {
    padding-right: 24px;
    margin: 8px 0;
}

@media (max-width: 900px) {
    .help-layout {
        grid-template-columns: 1fr;
        max-width: 210mm;
        margin: 0 auto;
    }
    .help-nav { position: static; max-height: none; }
    .help-toolbar { max-width: 100%; }
}

/* ─── طباعة A4 ─────────────────────────────────────────────── */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm 14mm;
    }

    body {
        background: #fff !important;
        font-size: 10pt;
    }

    .sidebar,
    .topbar,
    .help-nav,
    .help-toolbar,
    .menu-toggle,
    .alert,
    .app-modal,
    .no-print {
        display: none !important;
    }

    .app-layout {
        display: block !important;
        grid-template-columns: 1fr !important;
    }

    .main-content {
        margin: 0 !important;
        width: 100% !important;
    }

    .page-content {
        padding: 0 !important;
        margin: 0 !important;
    }

    .help-page {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: auto !important;
    }

    .help-layout {
        display: block !important;
    }

    .help-document {
        box-shadow: none !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        min-height: auto !important;
    }

    .help-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .help-module {
        border: 1px solid #ccc;
    }

    .help-module summary {
        list-style: none;
    }

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

    .help-table th {
        background: #714B67 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
