body {
    font-family: 'Cairo', sans-serif;
    background: radial-gradient(circle at top left, #f4f7fb 0%, #e9eff6 100%);
    color: #1e293b;
    overflow-x: hidden;
    width: 100vw;
}
.glassmorphism {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(0, 72, 131, 0.06);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.035);
}
.glass-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 72, 131, 0.05);
    box-shadow: 0 10px 30px -10px rgba(0, 72, 131, 0.05);
}
.spa-view {
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}
.spa-view.hidden-view {
    display: none;
    opacity: 0;
    transform: translateY(10px);
}
.modal-glass {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 72, 131, 0.08);
    box-shadow: 0 20px 60px rgba(0, 72, 131, 0.15);
}
body.theme-dark {
    background: linear-gradient(180deg, #0b1220 0%, #111827 100%) !important;
    color: #e5e7eb;
    color-scheme: dark;
}
body.theme-dark .glassmorphism,
body.theme-dark .glass-card,
body.theme-dark .modal-glass {
    background: rgba(17, 24, 39, 0.94) !important;
    border-color: rgba(148, 163, 184, 0.20) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
}
body.theme-dark .bg-white,
body.theme-dark .bg-white\/75,
body.theme-dark input,
body.theme-dark textarea,
body.theme-dark select,
body.theme-dark table,
body.theme-dark tbody {
    background-color: #111827 !important;
    color: #e2e8f0 !important;
    border-color: rgba(148, 163, 184, 0.22) !important;
}
body.theme-dark .text-primary {
    color: #e5eefb !important;
}
body.theme-dark .text-secondary {
    color: #fbbf24 !important;
}
body.theme-dark .bg-primary\/10 {
    background-color: rgba(59, 130, 246, 0.16) !important;
}
body.theme-dark .bg-secondary\/10,
body.theme-dark .bg-secondary\/15 {
    background-color: rgba(245, 158, 11, 0.16) !important;
}
body.theme-dark .bg-red-50,
body.theme-dark .bg-emerald-50,
body.theme-dark .bg-amber-50 {
    background-color: rgba(15, 23, 42, 0.78) !important;
}
body.theme-dark .bg-slate-50,
body.theme-dark .bg-slate-100,
body.theme-dark .bg-slate-100\/80,
body.theme-dark .bg-slate-50\/50 {
    background-color: rgba(30, 41, 59, 0.72) !important;
}
body.theme-dark .text-slate-800,
body.theme-dark .text-slate-700,
body.theme-dark .text-slate-600 {
    color: #e2e8f0 !important;
}
body.theme-dark .text-slate-500,
body.theme-dark .text-slate-400 {
    color: #94a3b8 !important;
}
body.theme-dark .border-slate-100,
body.theme-dark .border-slate-200,
body.theme-dark .border-slate-200\/50 {
    border-color: rgba(148, 163, 184, 0.18) !important;
}
body.theme-dark ::placeholder {
    color: #64748b !important;
}
body.theme-dark footer,
body.theme-dark .bg-white\/40 {
    background-color: rgba(15, 23, 42, 0.82) !important;
    color: #94a3b8 !important;
}
.mobile-tabbar {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(203, 213, 225, 0.9);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.055);
    backdrop-filter: none;
}
.nav-btn-mob svg {
    width: 1.08rem;
    height: 1.08rem;
}
.nav-btn-mob {
    min-width: 0;
    color: #64748b;
    border-radius: 1rem;
}
.nav-btn-mob span {
    font-size: 0.72rem;
    line-height: 1;
    white-space: nowrap;
}
.nav-btn-mob.text-primary {
    background: #eef6fb;
    color: #004883;
    box-shadow: inset 0 0 0 1px rgba(0, 72, 131, 0.08);
}
body.theme-dark .nav-btn-mob {
    color: #94a3b8;
}
body.theme-dark .mobile-tabbar {
    background: rgba(15, 23, 42, 0.98);
    border-color: rgba(148, 163, 184, 0.24);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.16);
}
body.theme-dark .nav-btn-mob.text-primary {
    background: rgba(251, 191, 36, 0.16);
    color: #f8fafc !important;
    border-color: transparent !important;
}
.header-menu-btn {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #004883;
    background: rgba(0, 72, 131, 0.08);
    border: 1px solid rgba(0, 72, 131, 0.14);
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.header-menu-btn:hover {
    background: rgba(0, 72, 131, 0.13);
    border-color: rgba(0, 72, 131, 0.22);
}
.header-menu-btn svg {
    width: 1.55rem;
    height: 1.55rem;
    stroke-width: 3.4;
}
@keyframes slideInFromRight {
    from { transform: translateX(100%); opacity: 0.75; }
    to { transform: translateX(0); opacity: 1; }
}
.mobile-sidebar-drawer {
    animation: slideInFromRight 0.22s ease-out both;
}
body.theme-dark .header-menu-btn {
    color: #f8fafc;
    background: rgba(148, 163, 184, 0.16);
    border-color: rgba(148, 163, 184, 0.24);
}
#quick-theme-toggle.quick-theme-button {
    background: #f8fafc !important;
    color: #004883 !important;
    border: 1px solid rgba(0, 72, 131, 0.13) !important;
    box-shadow: none !important;
}
#quick-theme-toggle.quick-theme-button:hover {
    background: #eef6fb !important;
}
#quick-theme-toggle.quick-theme-button svg {
    width: 1.18rem;
    height: 1.18rem;
    color: currentColor !important;
}
body.theme-dark #quick-theme-toggle.quick-theme-button {
    background: rgba(255, 255, 255, 0.10) !important;
    color: #fbbf24 !important;
    border-color: rgba(251, 191, 36, 0.22) !important;
}
.theme-toggle-btn {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.theme-toggle-btn:hover {
    transform: translateY(-1px);
}
body.theme-dark .theme-toggle-btn {
    background: rgba(30, 41, 59, 0.92);
    border-color: rgba(148, 163, 184, 0.22);
    color: #fbbf24;
}
.subscription-status-pill {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    border-radius: 999px;
    padding: 0.2rem 0.5rem;
    font-size: 0.56rem;
    font-weight: 900;
    line-height: 1;
    justify-content: center;
}
.subscription-avatar-badge {
    position: absolute;
    right: 50%;
    bottom: -0.32rem;
    transform: translateX(50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.3rem;
    max-width: 2.45rem;
    height: 1rem;
    padding: 0 0.28rem;
    border-radius: 999px;
    font-size: 0.48rem;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}
@media (min-width: 640px) {
    .subscription-avatar-badge {
        display: none;
    }
}
.subscription-profile-name-card {
    min-width: 11rem;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}
body.theme-dark .subscription-profile-name-card {
    background: rgba(15, 23, 42, 0.94);
    border-color: rgba(148, 163, 184, 0.2);
}
body.theme-dark .subscription-profile-name-card strong {
    color: #f8fafc !important;
}
.settings-toggle {
    width: 100%;
    min-height: 4.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    text-align: right;
}
.settings-chevron {
    width: 2rem;
    height: 2rem;
    border-radius: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 72, 131, 0.08);
    color: #004883;
    transition: transform .18s ease, background .18s ease;
    flex-shrink: 0;
}
.settings-toggle.is-open .settings-chevron {
    transform: rotate(180deg);
    background: rgba(241, 144, 32, 0.14);
    color: #b45309;
}
.settings-panel {
    border-top: 1px solid rgba(226, 232, 240, 0.72);
}
#view-settings > .max-w-4xl {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
#view-settings > .max-w-4xl > .glass-card {
    margin-top: 0 !important;
    scroll-margin-top: 8.5rem;
}
#currency-settings-card {
    order: 1;
}
#settings-colors-card {
    order: 2;
}
#settings-security-card {
    order: 3;
}
#settings-privacy-card {
    order: 4;
}
body.theme-dark .settings-chevron {
    background: rgba(148, 163, 184, 0.14);
    color: #f8fafc;
}
body.theme-dark .settings-panel {
    border-color: rgba(148, 163, 184, 0.18);
}
.category-section-card {
    border-radius: 1.25rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.78);
    padding: 1rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
body.theme-dark .category-section-card {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(148, 163, 184, 0.18);
}
.color-picker-card {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 0.95rem;
    border-radius: 1.25rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(248,250,252,0.92));
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}
.color-picker-input {
    width: 1.7rem;
    height: 1.7rem;
    padding: 0;
    border: 0;
    border-radius: 0.65rem;
    background: transparent;
    cursor: pointer;
}
.color-swatch-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
}
.color-swatch-btn {
    position: relative;
    aspect-ratio: 1;
    min-height: 2.25rem;
    border-radius: 0.9rem;
    border: 2px solid rgba(255,255,255,0.86);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12), 0 8px 18px rgba(15, 23, 42, 0.08);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.custom-color-btn {
    position: relative;
    grid-column: 1 / -1;
    min-height: 2.25rem;
    border-radius: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.color-swatch-btn.is-selected,
.custom-color-btn.is-selected {
    transform: translateY(-1px);
    border-color: rgba(0, 72, 131, 0.55) !important;
    box-shadow: 0 0 0 3px rgba(0, 72, 131, 0.14), 0 10px 22px rgba(15, 23, 42, 0.12);
}
.color-swatch-btn.is-selected::after,
.custom-color-btn.is-selected::after {
    content: "✓";
    position: absolute;
    top: -0.38rem;
    inset-inline-start: -0.38rem;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: #ffffff;
    color: #004883;
    border: 1px solid rgba(0, 72, 131, 0.22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 900;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.12);
}
.custom-color-btn .color-picker-input::-webkit-color-swatch-wrapper {
    padding: 0;
}
.custom-color-btn .color-picker-input::-webkit-color-swatch {
    border: 1px solid rgba(15, 23, 42, 0.16);
    border-radius: 0.65rem;
}
.custom-color-btn .color-picker-input::-moz-color-swatch {
    border: 1px solid rgba(15, 23, 42, 0.16);
    border-radius: 0.65rem;
}
.color-code {
    direction: ltr;
    text-align: left;
    align-self: flex-start;
    font-size: 0.64rem;
    font-weight: 900;
    color: #64748b;
    background: rgba(255,255,255,0.82);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
}
.color-preset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.75rem;
}
.color-preset-swatches {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
}
.color-preset-swatches i {
    display: block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.78);
    box-shadow: 0 0 0 1px rgba(15,23,42,0.08);
}
.custom-select-option.active {
    border-color: rgba(0, 72, 131, 0.22);
    background: rgba(0, 72, 131, 0.08);
    color: #004883;
}
body.theme-dark .custom-select-option.active {
    border-color: rgba(251, 191, 36, 0.35);
    background: rgba(251, 191, 36, 0.14);
    color: #f8fafc;
}
.recovery-codes-grid {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}
.recovery-codes-grid code {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}
body.theme-dark .recovery-codes-grid {
    background: rgba(15, 23, 42, 0.70);
    color: #e5e7eb;
    border-color: rgba(148, 163, 184, 0.20);
}
body.theme-dark .recovery-codes-grid code {
    background: rgba(30, 41, 59, 0.90);
    border-color: rgba(148, 163, 184, 0.18);
}
body.theme-dark .color-picker-card {
    background: linear-gradient(180deg, rgba(30,41,59,0.92), rgba(15,23,42,0.88));
    border-color: rgba(148, 163, 184, 0.20);
}
body.theme-dark .color-code {
    background: rgba(15, 23, 42, 0.72);
    border-color: rgba(148, 163, 184, 0.20);
    color: #cbd5e1;
}
.invoice-viewer-dialog {
    max-height: calc(100dvh - 2rem);
}
.invoice-viewer-stage {
    min-height: min(68dvh, 520px);
    max-height: calc(100dvh - 10rem);
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
.invoice-viewer-media {
    max-width: 100%;
    max-height: calc(100dvh - 12rem);
}
.note-image-viewer-dialog {
    max-height: calc(100dvh - 2rem);
}
.note-image-viewer-stage {
    min-height: min(68dvh, 520px);
    max-height: calc(100dvh - 9rem);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.note-image-viewer-media {
    max-width: 100%;
    max-height: calc(100dvh - 11rem);
}
.invoice-document-modal {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}
.invoice-document-modal #invoice-printable-document {
    flex: 0 0 auto;
}

/* أنماط طباعة مخصصة عالية الدقة لإنشاء وحفظ ملفات الـ PDF بأمان تام دون حظر المتصفحات */
@media print {
    body { background: #ffffff !important; color: #000000 !important; font-size: 12px !important; overflow: visible !important; }
    body > *:not(#print-section-container) { display: none !important; }
    #print-section-container {
        display: block !important;
        position: static !important;
        inset: auto !important;
        width: 100% !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        direction: rtl !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: auto !important;
        background: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
#print-section-container {
    display: block;
    position: fixed;
    top: 0;
    left: -10000px;
    width: 210mm;
    min-height: 1px;
    overflow: visible;
    background: #ffffff;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}
.ltr { direction: ltr; text-align: left; }
button,
input,
textarea,
select {
    font-family: 'Cairo', sans-serif;
    letter-spacing: 0;
}
button,
a,
input,
textarea,
select {
    -webkit-tap-highlight-color: transparent;
}
button {
    line-height: 1.45;
}
.glass-card input,
.glass-card textarea,
.glass-card select,
.modal-glass input,
.modal-glass textarea,
.modal-glass select {
    font-size: 0.84rem;
    line-height: 1.65;
}
.glass-card button,
.modal-glass button,
.nav-btn {
    min-height: 2.55rem;
}
.nav-btn,
.nav-btn-mob,
.settings-toggle,
.glass-card h2,
.glass-card h3,
.glass-card h4 {
    overflow-wrap: anywhere;
}
.notes-grid {
    columns: 1;
    column-gap: 1rem;
}
@media (min-width: 768px) {
    .notes-grid {
        columns: 2;
    }
}
.note-card {
    break-inside: avoid;
    display: inline-block;
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}
.note-color-btn.is-selected {
    box-shadow: 0 0 0 3px rgba(0, 72, 131, 0.16);
    border-color: rgba(0, 72, 131, 0.55) !important;
}
.note-content-preview {
    white-space: pre-wrap;
    word-break: break-word;
}
.note-type-btn {
    background: #ffffff !important;
    border-color: rgba(203, 213, 225, 0.95) !important;
    color: #475569 !important;
    line-height: 1.45;
    min-height: 4rem;
    white-space: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: visible;
}
.note-type-btn.is-selected {
    background: var(--root-primary-color) !important;
    border-color: var(--root-primary-color) !important;
    color: #fff !important;
    box-shadow: 0 10px 22px rgba(0, 72, 131, 0.16);
}
#note-drawing-undo-btn:disabled {
    cursor: not-allowed;
}
.note-checklist-preview li {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    line-height: 1.7;
    margin-top: 0.35rem;
}
.note-checklist-preview .is-done {
    text-decoration: line-through;
    color: rgb(100, 116, 139);
}
.note-drawing-canvas {
    touch-action: none;
    cursor: crosshair;
}
.note-images-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}
.note-images-grid > button:first-child {
    grid-column: 1 / -1;
}
.note-images-grid.is-single {
    display: block;
}
.note-image-thumb img,
.note-images-grid img {
    background: #fff;
}
.note-drawing-preview {
    max-height: 14rem;
    object-fit: contain;
    background: #fff;
}
body.theme-dark .note-card {
    background-color: rgba(30, 41, 59, 0.92) !important;
    border-color: rgba(148, 163, 184, 0.22);
}
.app-lock-overlay {
    background: rgba(246, 248, 252, 0.92);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
body.theme-dark .app-lock-overlay {
    background: rgba(11, 18, 32, 0.94);
}
.app-lock-pin-input {
    letter-spacing: 0.42rem;
    direction: ltr;
    text-align: center;
    font-size: 1.45rem !important;
    font-weight: 900;
}
body.app-locked {
    overflow: hidden;
}

@media (min-width: 768px) and (max-width: 1024px) {
    body {
        flex-direction: column !important;
        padding-bottom: calc(6rem + env(safe-area-inset-bottom)) !important;
    }
    .hidden.md\:block,
    .hidden.md\:flex {
        display: none !important;
    }
    .md\:hidden {
        display: block !important;
    }
    aside.hidden.md\:flex {
        display: none !important;
    }
    button.md\:hidden,
    .header-menu-btn.md\:hidden,
    .mobile-tabbar.md\:hidden,
    nav.mobile-tabbar.md\:hidden {
        display: flex !important;
    }
    .header-menu-btn.md\:hidden,
    .header-menu-btn {
        display: inline-flex !important;
    }
    main.flex-grow {
        width: 100% !important;
        padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(7rem + env(safe-area-inset-bottom)) !important;
    }
    #desktop-refresh-btn.hidden.md\:flex {
        display: none !important;
    }
}

@media (max-width: 480px) {
    html {
        scroll-padding-top: 7.5rem;
        scroll-padding-bottom: 8rem;
    }
    header.glassmorphism {
        position: relative !important;
        padding: 0.65rem !important;
        gap: 0.5rem !important;
        top: auto !important;
    }
    main.flex-grow {
        padding: calc(0.75rem + env(safe-area-inset-top)) 0.75rem calc(8rem + env(safe-area-inset-bottom)) !important;
    }
    #view-settings {
        padding-bottom: 7rem;
    }
    .settings-panel {
        padding: 1rem !important;
    }
    .invoice-viewer-dialog {
        max-height: calc(100dvh - 1rem);
        border-radius: 1.25rem !important;
        padding: 1rem !important;
    }
    .invoice-viewer-stage {
        min-height: 65dvh;
        max-height: calc(100dvh - 8.5rem);
        padding: 0.35rem !important;
        align-items: flex-start;
    }
    #invoice-viewer-img.invoice-viewer-media {
        width: 100%;
        height: auto;
        max-height: none;
    }
    #invoice-viewer-pdf.invoice-viewer-media {
        height: 72dvh;
        max-height: none;
    }
    .invoice-document-modal {
        height: 100svh !important;
        max-height: 100svh !important;
    }
}
