/* ==========================================================================
   دفتر — نظام التصميم v2 (زمردي · قائمة جانبية · فاتح + ليلي)
   كل الألوان من tokens — ممنوع ألوان ثابتة مبعثرة.
   ========================================================================== */

:root {
    --bs-primary-rgb: 13, 148, 136;
    --bs-link-color: #0b7c71;
    --bs-link-color-rgb: 11, 124, 113;
    --bs-link-hover-color: #085f57;
    --bs-link-hover-color-rgb: 8, 95, 87;
    /* الألوان — هوية زمردية/تركوازية */
    --app-bg: #edf2f0;
    --app-surface: #ffffff;
    --app-surface-2: #f3f7f5;
    --app-ink: #12211d;
    --app-muted: #5d726c;
    --app-line: #dce7e3;
    --app-brand: #0d9488;
    --app-brand-strong: #0b7c71;
    --app-brand-soft: rgba(13, 148, 136, .11);
    --app-success: #059669;
    --app-success-soft: rgba(5, 150, 105, .12);
    --app-danger: #dc2626;
    --app-danger-soft: rgba(220, 38, 38, .09);
    --app-warning: #b45309;
    --app-warning-soft: rgba(217, 119, 6, .13);

    /* القائمة الجانبية */
    --side-bg: linear-gradient(178deg, #0a3b35 0%, #0d5a50 100%);
    --side-ink: rgba(255, 255, 255, .78);
    --side-muted: rgba(255, 255, 255, .5);
    --side-active-bg: #ffffff;
    --side-active-ink: #0b5a50;
    --side-hover: rgba(255, 255, 255, .09);

    /* الزوايا والظلال */
    --app-radius-sm: 12px;
    --app-radius: 16px;
    --app-radius-lg: 22px;
    --app-shadow-sm: 0 1px 2px rgba(18, 33, 29, .05);
    --app-shadow: 0 1px 3px rgba(18, 33, 29, .05), 0 10px 28px rgba(18, 33, 29, .07);
    --app-shadow-lg: 0 16px 48px rgba(10, 59, 53, .16);

    --app-font: 'Tajawal', "Segoe UI", Tahoma, "Noto Kufi Arabic", system-ui, -apple-system, sans-serif;

    color-scheme: light;
}

[data-bs-theme="dark"] {
    --bs-primary-rgb: 45, 212, 191;
    --bs-link-color: #5eead4;
    --bs-link-color-rgb: 94, 234, 212;
    --bs-link-hover-color: #99f6e4;
    --bs-link-hover-color-rgb: 153, 246, 228;
    --app-bg: #0a1210;
    --app-surface: #101d1a;
    --app-surface-2: #15241f;
    --app-ink: #e4efec;
    --app-muted: #8aa49d;
    --app-line: #213430;
    --app-brand: #2dd4bf;
    --app-brand-strong: #5eead4;
    --app-brand-soft: rgba(45, 212, 191, .13);
    --app-success: #34d399;
    --app-success-soft: rgba(52, 211, 153, .13);
    --app-danger: #f87171;
    --app-danger-soft: rgba(248, 113, 113, .12);
    --app-warning: #fbbf24;
    --app-warning-soft: rgba(251, 191, 36, .13);

    --side-bg: linear-gradient(178deg, #071a17 0%, #0a2420 100%);
    --side-ink: rgba(255, 255, 255, .72);
    --side-muted: rgba(255, 255, 255, .42);
    --side-active-bg: #2dd4bf;
    --side-active-ink: #06231f;
    --side-hover: rgba(255, 255, 255, .07);

    --app-shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --app-shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .35);
    --app-shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);

    color-scheme: dark;
}

body {
    background: var(--app-bg);
    color: var(--app-ink);
    font-family: var(--app-font);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── الهيكل: قائمة جانبية + محتوى ──────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 264px;
    flex: 0 0 264px;
    background: var(--side-bg);
    color: var(--side-ink);
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1.1rem .8rem;
    scrollbar-width: thin;
}

.app-sidebar .side-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .25rem .6rem 1.1rem;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.15rem;
}

.app-sidebar .side-section {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--side-muted);
    padding: .9rem .7rem .35rem;
    text-transform: uppercase;
}

.side-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    margin-bottom: 2px;
    border-radius: var(--app-radius-sm);
    color: var(--side-ink);
    text-decoration: none;
    font-size: .94rem;
    font-weight: 500;
    transition: background .14s ease, color .14s ease;
    position: relative;
}

.side-link i { font-size: 1.05rem; width: 22px; text-align: center; }

.side-link:hover {
    background: var(--side-hover);
    color: #fff;
}

.side-link.active {
    background: var(--side-active-bg);
    color: var(--side-active-ink);
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

.side-link .badge {
    margin-inline-start: auto;
}

.side-theme {
    margin-top: auto;
    width: 100%;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: var(--app-radius-sm);
    background: transparent;
    color: var(--side-ink);
    font-size: .9rem;
    font-weight: 500;
    transition: background .14s ease;
}

.side-theme:hover { background: var(--side-hover); color: #fff; }

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* الشريط العلوي (داخل عمود المحتوى) */
.app-topbar {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem 1.25rem;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-topbar .navbar-brand {
    font-weight: 800;
    color: var(--app-ink);
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ── وضع التطبيق المثبَّت (PWA): نحترم شريط الحالة و«النتوء» ───────────── */
@media (display-mode: standalone) {
    body { min-height: 100dvh; }
    .app-topbar { padding-top: calc(.7rem + env(safe-area-inset-top)); }
    .app-footer { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
    .app-main main.container-fluid {
        padding-left: calc(1rem + env(safe-area-inset-left));
        padding-right: calc(1rem + env(safe-area-inset-right));
    }
}

/* ── شريط التنقل السفلي (الجوال) ───────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    z-index: 1030;
    display: flex;
    background: var(--app-surface);
    border-top: 1px solid var(--app-line);
    box-shadow: 0 -6px 24px rgba(10, 59, 53, .08);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav .bn-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    color: var(--app-muted);
    font-size: .66rem;
    font-weight: 500;
    text-decoration: none;
    border: 0;
    background: transparent;
    position: relative;
    transition: color .15s ease;
}

.bottom-nav .bn-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bottom-nav .bn-item i { font-size: 1.2rem; }
.bottom-nav .bn-item:hover { color: var(--app-brand); }

.bottom-nav .bn-item.active {
    color: var(--app-brand);
    font-weight: 700;
}

.bottom-nav .bn-item .bn-badge {
    position: absolute;
    top: 6px;
    inset-inline-start: calc(50% - 18px);
    font-size: .62rem;
}

.bottom-nav .bn-add {
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    margin: -18px 6px 0;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--app-brand), var(--app-brand-strong));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(13, 148, 136, .4);
    border: 4px solid var(--app-bg);
    transition: transform .12s ease;
}

.bottom-nav .bn-add:active { transform: scale(.94); }

@media (max-width: 991.98px) {
    body.has-bottom-nav .app-main main { padding-bottom: 92px; }
    body.has-bottom-nav .app-footer { margin-bottom: 72px; }
}

/* قائمة «المزيد» المنبثقة */
.more-offcanvas .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .9rem;
    border-radius: var(--app-radius-sm);
    color: var(--app-ink);
    font-weight: 500;
}

.more-offcanvas .nav-link:hover { background: var(--app-brand-soft); color: var(--app-brand-strong); }
.more-offcanvas .nav-link.active { background: var(--app-brand-soft); color: var(--app-brand-strong); font-weight: 700; }
.more-offcanvas .nav-link i { font-size: 1.1rem; width: 22px; text-align: center; color: var(--app-muted); }
.more-offcanvas .nav-link.active i, .more-offcanvas .nav-link:hover i { color: var(--app-brand); }

/* ── رأس الصفحة الموحّد ────────────────────────────────────────────────── */
.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.page-head .ph-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -.01em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.page-head .ph-title i { color: var(--app-brand); font-size: 1.2rem; }

.page-head .ph-sub {
    color: var(--app-muted);
    font-size: .88rem;
    margin: .15rem 0 0;
}

.page-head .ph-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

/* ── بطاقات ────────────────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-sm);
    background: var(--app-surface);
    transition: box-shadow .18s ease;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--app-line);
    font-weight: 700;
    padding: .85rem 1.1rem;
}

/* ── بطاقات الإحصاء ────────────────────────────────────────────────────── */
.stat-card { height: 100%; }

.stat-card .stat-value {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
}

.stat-card .stat-label {
    color: var(--app-muted);
    font-size: .83rem;
    font-weight: 500;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: var(--app-brand-soft);
    color: var(--app-brand);
    flex: 0 0 auto;
}

.stat-icon.is-success { background: var(--app-success-soft); color: var(--app-success); }
.stat-icon.is-danger { background: var(--app-danger-soft); color: var(--app-danger); }
.stat-icon.is-warning { background: var(--app-warning-soft); color: var(--app-warning); }

/* ── شرائط النِسَب ─────────────────────────────────────────────────────── */
.bar-track {
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--app-brand), var(--app-brand-strong));
    transition: width .4s ease;
}

.bar-fill.alt { background: linear-gradient(90deg, var(--app-success), #0d9488); }

/* ── جداول ─────────────────────────────────────────────────────────────── */
.table {
    --bs-table-bg: transparent;
    font-size: .92rem;
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: .65rem .55rem;
    border-bottom-color: var(--app-line);
}

.table thead th {
    color: var(--app-muted);
    font-weight: 700;
    font-size: .78rem;
    white-space: nowrap;
}

.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--app-surface-2); }

/* ── تابات الإعدادات ───────────────────────────────────────────────────── */
.app-tabs {
    gap: .35rem;
    border-bottom: 1px solid var(--app-line);
    padding-bottom: .6rem;
}

.app-tabs .nav-link {
    color: var(--app-muted);
    border-radius: 999px;
    font-size: .93rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 1rem;
    transition: background .15s ease, color .15s ease;
}

.app-tabs .nav-link:hover {
    background: var(--app-brand-soft);
    color: var(--app-brand-strong);
}

.app-tabs .nav-link.active {
    background: var(--app-brand);
    color: #fff;
}

.app-tabs .nav-link.active .badge {
    background: rgba(255, 255, 255, .28) !important;
    color: #fff;
}

/* ── شريط الأيام ───────────────────────────────────────────────────────── */
.day-strip {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 84px;
    padding: .35rem;
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius-sm);
}

.day-cell {
    flex: 1 1 0;
    min-width: 3px;
    background: var(--app-brand);
    border-radius: 3px 3px 0 0;
    opacity: .8;
    transition: opacity .15s ease, background .15s ease;
}

.day-cell:hover {
    opacity: 1;
    background: var(--app-brand-strong);
}

/* ── مبالغ وشارات ──────────────────────────────────────────────────────── */
.amount {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    white-space: nowrap;
}

.amount.out { color: var(--app-danger); }
.amount.in { color: var(--app-success); }

.flag-badge {
    font-size: .72rem;
    font-weight: 500;
}

.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-inline-end: .35rem;
    box-shadow: 0 0 0 2px var(--app-surface);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .82rem;
}

/* ── عنصر حركة (بطاقة الجوال بدل الجدول) ───────────────────────────────── */
.entry-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem .35rem;
    border-bottom: 1px solid var(--app-line);
}

.entry-item:last-child { border-bottom: 0; }
.entry-item .ei-main { flex: 1 1 auto; min-width: 0; }

.entry-item .ei-desc {
    font-weight: 600;
    font-size: .92rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-item .ei-meta {
    color: var(--app-muted);
    font-size: .78rem;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
    margin-top: .15rem;
}

.entry-item .ei-actions {
    display: flex;
    gap: .25rem;
    flex: 0 0 auto;
}

/* ── المحادثة / المسجّل ────────────────────────────────────────────────── */
.chat-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--app-line);
    margin-bottom: .9rem;
}

.thread {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: .5rem;
}

.msg { display: flex; flex-direction: column; gap: .5rem; }

/* في الاتجاه العربي: flex-start = يمين (المستخدم) · flex-end = يسار (المساعد) */
.msg-user { align-items: flex-start; }
.msg-assistant { align-items: flex-end; }

.msg-cards {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.bubble {
    border-radius: var(--app-radius);
    padding: .7rem .95rem;
    max-width: 92%;
    white-space: pre-wrap;
    font-size: .92rem;
    line-height: 1.8;
}

.bubble.user {
    align-self: flex-start;
    background: var(--app-brand-soft);
    border: 1px solid var(--app-line);
}

.bubble.assistant {
    align-self: flex-end;
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
}

.bubble.answer {
    background: var(--app-surface);
    border-color: var(--app-brand);
    box-shadow: 0 0 0 3px var(--app-brand-soft);
}

.bubble-meta {
    font-size: .72rem;
    color: var(--app-muted);
    margin-top: .35rem;
}

.bubble-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--app-brand);
    margin-bottom: .3rem;
}

.thread-sep { display: flex; justify-content: center; }

.thread-sep span {
    font-size: .72rem;
    color: var(--app-muted);
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: 999px;
    padding: .15rem .85rem;
}

.thread-empty {
    text-align: center;
    color: var(--app-muted);
    padding: 2.5rem 1rem;
}

.thread-empty i { font-size: 1.7rem; color: var(--app-brand); }

.thread-tools {
    border-top: 1px dashed var(--app-line);
    padding-top: .7rem;
    font-size: .85rem;
}

.thread-tools > summary { cursor: pointer; color: var(--app-muted); }

.pending-card {
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius);
    background: var(--app-surface);
    padding: .8rem .95rem;
    box-shadow: var(--app-shadow-sm);
}

.pending-card .card-flags .badge { margin-inline-end: .25rem; }

.pending-flash { animation: pendingFlash 1.4s ease-out 1; }

@keyframes pendingFlash {
    0% { box-shadow: 0 0 0 4px var(--app-brand-soft), 0 0 0 6px var(--app-brand); }
    100% { box-shadow: none; }
}

/* خانة الكتابة ثابتة تحت — إحساس تطبيق محادثة */
.composer-dock {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: var(--app-bg);
    border-top: 1px solid var(--app-line);
    padding: .6rem 0 calc(.4rem + env(safe-area-inset-bottom));
    margin-top: .3rem;
}

.composer textarea {
    min-height: 48px;
    max-height: 170px;
    font-size: .95rem;
    line-height: 1.7;
}

.composer-send {
    height: 48px;
    min-width: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    flex: 0 0 auto;
}

/* رقائق الأمثلة */
.example-chips {
    display: flex;
    gap: .4rem;
    overflow-x: auto;
    padding: .1rem 0 .35rem;
    scrollbar-width: thin;
}

.example-chips .btn { white-space: nowrap; flex: 0 0 auto; }

/* ── الدخول ────────────────────────────────────────────────────────────── */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    background:
        radial-gradient(55rem 28rem at 85% -10%, var(--app-brand-soft), transparent 60%),
        linear-gradient(160deg, var(--app-brand-soft) 0%, var(--app-bg) 55%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-lg);
    padding: 2.1rem;
}

.auth-card .form-control { min-height: 48px; font-size: .95rem; }
.auth-card .btn-primary { min-height: 48px; font-weight: 700; }

/* ── التذييل ───────────────────────────────────────────────────────────── */
.app-footer {
    margin-top: auto;
    padding: 1rem 0;
    color: var(--app-muted);
    font-size: .8rem;
    border-top: 1px solid var(--app-line);
    background: var(--app-surface);
}

/* ── حالات فارغة ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    color: var(--app-muted);
    padding: 2rem 1rem;
}

.empty-state i {
    font-size: 2rem;
    display: block;
    margin-bottom: .5rem;
    opacity: .5;
}

/* ── صورة رمزية بالحرف الأول (صفحة المستخدمين) ─────────────────────────── */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    background: var(--app-brand-soft);
    color: var(--app-brand-strong);
    flex: 0 0 auto;
}

.user-avatar.is-admin { background: var(--app-ink); color: var(--app-bg); }
.user-avatar.is-off { background: var(--app-surface-2); color: var(--app-muted); }

/* ── علامة العلامة التجارية ────────────────────────────────────────────── */
.brand-mark {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(145deg, #14b8a6, #0d9488);
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(13, 148, 136, .35);
}

.brand-mark-lg {
    width: 62px;
    height: 62px;
    border-radius: 19px;
    font-size: 1.75rem;
    margin: 0 auto;
}

/* ── مودالات ───────────────────────────────────────────────────────────── */
.modal-content {
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-lg);
    background: var(--app-surface);
}

.modal-header { background: var(--app-surface); border-bottom: 1px solid var(--app-line); }
.modal-footer { border-top: 1px solid var(--app-line); }

/* ── نماذج ─────────────────────────────────────────────────────────────── */
.form-label {
    font-size: .85rem;
    font-weight: 700;
    color: var(--app-ink);
}

.form-control, .form-select {
    border-color: var(--app-line);
    border-radius: var(--app-radius-sm);
    background-color: var(--app-surface);
    color: var(--app-ink);
}

.form-control:focus, .form-select:focus {
    border-color: var(--app-brand);
    box-shadow: 0 0 0 3px var(--app-brand-soft);
    background-color: var(--app-surface);
    color: var(--app-ink);
}

.form-control::placeholder { color: var(--app-muted); opacity: .7; }
.form-text { color: var(--app-muted); }

.form-check-input:checked {
    background-color: var(--app-brand);
    border-color: var(--app-brand);
}

/* ── أزرار ─────────────────────────────────────────────────────────────── */
.btn {
    font-weight: 600;
    border-radius: var(--app-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
}

.btn-primary {
    --bs-btn-bg: var(--app-brand);
    --bs-btn-border-color: var(--app-brand);
    --bs-btn-hover-bg: var(--app-brand-strong);
    --bs-btn-hover-border-color: var(--app-brand-strong);
    --bs-btn-active-bg: var(--app-brand-strong);
    --bs-btn-active-border-color: var(--app-brand-strong);
}

/* أهداف لمس مريحة على الجوال */
@media (max-width: 991.98px) {
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; }
    .form-control, .form-select { min-height: 44px; font-size: 1rem; }
    .form-control-sm, .form-select-sm { min-height: 40px; }
}

/* ── فلاشات ────────────────────────────────────────────────────────────── */
.alert {
    border-radius: var(--app-radius);
    font-size: .92rem;
}

/* الروابط داخل التنبيهات ترث لون التنبيه — مقروءة في الفاتح والليلي */
.alert a {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
}

/* ── شاشات صغيرة ───────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    .stat-card .stat-value { font-size: 1.3rem; }
    .bubble { max-width: 100%; }
    .page-head .ph-title { font-size: 1.15rem; }
    .chat-head { position: sticky; top: 0; z-index: 6; background: var(--app-bg); }
    .composer textarea { font-size: 1rem; }
}

/* ── كروت الدفاتر والتصنيفات ───────────────────────────────────────────── */
.ledger-card { transition: transform .15s ease, box-shadow .18s ease; }
.ledger-card:hover { transform: translateY(-2px); box-shadow: var(--app-shadow); }
.ledger-card-off { opacity: .62; }

.ledger-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    flex: 0 0 auto;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

.lc-label {
    color: var(--app-muted);
    font-size: .72rem;
    font-weight: 500;
}

/* Focus, touch targets and viewport sizing are shared across every page. */
html { scroll-padding-top: 5rem; }
:focus-visible { outline: 3px solid var(--app-brand); outline-offset: 3px; }
.skip-link { position: fixed; top: .5rem; inset-inline-start: .5rem; z-index: 2000;
    padding: .75rem 1rem; border-radius: 12px; background: var(--app-surface); color: var(--app-ink);
    transform: translateY(-160%); box-shadow: var(--app-shadow); }
.skip-link:focus { transform: translateY(0); }
.connection-notice { position: sticky; top: 0; z-index: 1060; padding: .6rem 1rem;
    text-align: center; background: var(--app-warning-soft); color: var(--app-ink); font-size: .9rem; }
.app-main, .card, .card-body, .entry-item { overflow-wrap: anywhere; }
.table-responsive { overscroll-behavior-inline: contain; }
.btn[aria-disabled="true"] { opacity: .7; cursor: progress; pointer-events: none; }
input, select, textarea { max-width: 100%; }
.form-control:focus, .form-select:focus { border-color: var(--app-brand); box-shadow: 0 0 0 .2rem var(--app-brand-soft); }
@supports (height: 100dvh) {
    body, .app-shell { min-height: 100dvh; }
    .app-sidebar { height: 100dvh; }
}
@media (max-width: 575.98px) {
    .form-control, .form-select { font-size: 1rem; }
    .btn-sm { min-height: 40px; }
    .auth-body { padding: 1rem; }
    .auth-card { padding: 1.5rem; }
    .table-responsive .table { min-width: 620px; }
    .app-main main { padding-inline: 1rem !important; }
    .page-head { gap: .75rem; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important;
        animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
    .app-sidebar, .bottom-nav, .app-topbar, .skip-link, .connection-notice, form, .btn { display: none !important; }
    body, .app-main, .card { background: #fff !important; color: #000 !important; box-shadow: none !important; }
    .app-shell, .app-main { display: block; width: 100%; }
    .table-responsive { overflow: visible; }
}
