:root {
    --sidebar-w:  248px;
    --sidebar-gap: 14px;
    --card: #fff; --page: #f6f5fb; --s1: #f8f6ff; --s2: #f1f5f9; --soft: #f3effe; --soft2: #e9e1fd;
    --t1: #171a3a; --t2: #475569; --t3: #64748b; --t4: #94a3b8; --line: #ebe8f4; --line2: #d6d0e6; --brand-ink: #5a2fd6;
    --primary:    #6a3de8;
    --primary-d:  #4a25b8;
    --primary-l:  #8259ee;
    --bs-primary: #6a3de8;
    --bs-primary-rgb: 106,61,232;
    --bs-link-color: #5a2fd6;
    --bs-link-color-rgb: 90,47,214;
    --bs-link-hover-color: #4a25b8;
    --bs-link-hover-color-rgb: 74,37,184;
    --sidebar-tx: #8b96b5;
    --radius-xl:  18px;
    --radius-lg:  14px;
    --radius-md:  10px;
    --radius-sm:  7px;
    --shadow-xs:  0 1px 2px rgba(15,23,42,.05);
    --shadow-sm:  0 1px 3px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.04);
    --shadow-md:  0 4px 16px rgba(15,23,42,.09), 0 2px 6px rgba(15,23,42,.04);
    --shadow-lg:  0 12px 32px rgba(15,23,42,.11), 0 4px 10px rgba(15,23,42,.06);
}
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--page);
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    font-size: .9rem;
    color: var(--t1);
    min-height: 100vh;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--t4); }

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--card);
    position: fixed;
    top: var(--sidebar-gap); bottom: var(--sidebar-gap);
    inset-inline-start: var(--sidebar-gap);
    z-index: 1000;
    overflow: hidden;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 8px 28px rgba(59,31,143,.07);
}

/* ── Brand ── */
.sidebar-brand { padding: 1.1rem 1.1rem .9rem; flex-shrink: 0; }
.sidebar-brand h5 { color: var(--t1); margin: 0; font-weight: 800; font-size: 1.08rem; line-height: 1.2; }
.sidebar-brand small { color: var(--t3); font-size: .72rem; }

/* ── Section labels ── */
.sidebar-nav { padding: 0 .7rem .8rem; flex: 1; overflow-y: auto; min-height: 0; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-section {
    padding: .95rem .7rem .3rem;
    font-size: .7rem;
    color: var(--t3);
    font-weight: 700;
}

/* ── Nav links ── */
.sidebar-nav .nav-link {
    color: var(--t2);
    margin: .1rem 0;
    padding: .5rem .7rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .86rem;
    font-weight: 600;
    transition: background .13s, color .13s;
}
.sidebar-nav .nav-link:hover { background: var(--s1); color: var(--t1); }
.sidebar-nav .nav-link.active { background: var(--soft); color: var(--brand-ink); font-weight: 700; }
.sidebar-nav .nav-link i { font-size: 1.02rem; width: 1.15rem; text-align: center; flex-shrink: 0; color: var(--t4); transition: color .13s; }
.sidebar-nav .nav-link:hover i { color: var(--brand-ink); }
.sidebar-nav .nav-link.active i { color: var(--brand-ink); }

/* ── Account at the bottom ── */
.sidebar-user { display: flex; align-items: center; gap: .55rem; margin: 0 .7rem .7rem; padding: .55rem .6rem; border-radius: 14px; background: var(--s1); text-decoration: none; flex-shrink: 0; }
.sidebar-user:hover { background: var(--soft); }
.sidebar-user .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #5a2fd6, #8259ee); color: #fff; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.sidebar-user b { display: block; font-size: .8rem; color: var(--t1); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user small { display: block; font-size: .68rem; color: var(--t3); }
.sidebar-user > span:last-child { min-width: 0; }

/* ══════════════════════════════════════
   MAIN WRAPPER
══════════════════════════════════════ */
.main-wrapper {
    margin-inline-start: calc(var(--sidebar-w) + var(--sidebar-gap));
    min-height: 100vh;
    display: flex; flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: .65rem 1.2rem;
    margin: var(--sidebar-gap) var(--sidebar-gap) 0;
    position: sticky; top: var(--sidebar-gap);
    z-index: 900;
    display: flex; align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 64px;
    /* Covers the strip above it, so scrolled content does not show through the gap */
    box-shadow: 0 calc(var(--sidebar-gap) * -1 - 1px) 0 var(--page), 0 8px 28px rgba(59,31,143,.05);
}
.topbar-title { font-size: 1rem; font-weight: 700; margin: 0; line-height: 1.2; color: var(--t1); }
.topbar-sub { font-size: .72rem; color: var(--t3); margin-top: 1px; }

/* ── Page body ── */
.page-body { padding: 1.2rem var(--sidebar-gap) 1.5rem; flex: 1; }

/* ══════════════════════════════════════
   KPI CARDS
══════════════════════════════════════ */
.kpi-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 1.3rem 1.35rem 1.15rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--kpi-accent, var(--primary));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.kpi-card::after {
    content: '';
    position: absolute;
    inset-inline-end: -16px;
    top: -16px;
    width: 72px; height: 72px;
    background: var(--kpi-accent, var(--primary));
    opacity: .055;
    border-radius: 50%;
}
.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.kpi-icon {
    width: 46px; height: 46px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.kpi-value {
    font-size: 1.9rem; font-weight: 800; line-height: 1.1;
    margin-top: .5rem; letter-spacing: -.02em;
}
.kpi-label {
    font-size: .72rem; color: var(--t3); margin-top: .2rem;
    font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}

/* ══════════════════════════════════════
   CHART / INFO CARDS
══════════════════════════════════════ */
.chart-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 1.3rem 1.4rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
}
.chart-card .card-title {
    font-size: .75rem;
    font-weight: 700;
    color: var(--t2);
    margin-bottom: 1rem;
    padding-bottom: .7rem;
    border-bottom: 1px solid var(--s2);
    text-transform: uppercase;
    letter-spacing: .06em;
    display: flex; align-items: center; gap: .35rem;
}
.filter-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 1.05rem 1.4rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    margin-bottom: 1.25rem;
}

/* ══════════════════════════════════════
   TABLE CARDS
══════════════════════════════════════ */
.table-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    overflow: hidden;
}
.table-card-header {
    padding: .9rem 1.3rem;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, var(--s1) 0%, var(--s1) 100%);
}
.table-card-header .tc-title {
    font-size: .75rem; font-weight: 700; color: var(--t2);
    text-transform: uppercase; letter-spacing: .06em;
    display: flex; align-items: center; gap: .35rem;
}
.table-card .table { margin: 0; }
.table-card .table thead th {
    background: var(--s1);
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--t3);
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    padding: .7rem 1.1rem;
    white-space: nowrap;
}
.table-card .table tbody td {
    padding: .75rem 1.1rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table-card .table tbody tr:last-child td { border-bottom: none; }
.table-card .table tbody tr:hover td { background: var(--s1); }
.table-card .table tfoot td {
    background: var(--s1); font-size: .84rem;
    padding: .72rem 1.1rem; font-weight: 700;
    border-top: 1px solid var(--line);
}

/* ══════════════════════════════════════
   BADGES
══════════════════════════════════════ */
.badge {
    font-weight: 600; font-size: .68rem;
    padding: .3em .78em; border-radius: 30px; letter-spacing: .01em;
}
.status-active      { background: #dcfce7; color: #166534; }
.status-completed   { background: #dbeafe; color: #1e40af; }
.status-pending     { background: #fef9c3; color: #854d0e; }
.status-inactive    { background: var(--s2); color: var(--t2); }
.status-on_hold     { background: #fce7f3; color: #9d174d; }
.status-cancelled   { background: #fee2e2; color: #991b1b; }
.status-in_progress { background: var(--soft); color: #5b21b6; }
.status-closed      { background: var(--s2); color: var(--t2); }
.status-paid        { background: #dcfce7; color: #166534; }
.status-reimbursed  { background: #e0f2fe; color: #0c4a6e; }

/* ══════════════════════════════════════
   SUMMARY BOX
══════════════════════════════════════ */
.summary-box {
    border-radius: var(--radius-xl);
    padding: 1.1rem 1.4rem;
    display: flex; align-items: flex-start; gap: 1rem;
    margin-bottom: 1.25rem;
}
.summary-box .sb-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.summary-box .sb-label {
    font-size: .67rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; opacity: .55; margin-bottom: .25rem;
}
.summary-box p { margin: 0; font-size: .9rem; line-height: 1.6; }

/* ══════════════════════════════════════
   EMPTY STATES
══════════════════════════════════════ */
.chart-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--t4); font-size: .82rem;
    min-height: 140px; gap: .5rem;
}
.chart-empty i { font-size: 2.5rem; opacity: .2; }
.table-empty { text-align: center; color: var(--t4); padding: 3rem 1rem; }
.table-empty i { font-size: 2.8rem; opacity: .18; display: block; margin-bottom: .6rem; }

/* ══════════════════════════════════════
   ALERTS
══════════════════════════════════════ */
.alert {
    border-radius: var(--radius-md);
    border: none;
    font-size: .85rem;
    font-weight: 500;
    box-shadow: var(--shadow-xs);
}
.alert-success {
    background: linear-gradient(to right, #dcfce7, #f0fdf4);
    color: #166534;
    border-inline-start: 4px solid #22c55e;
}

/* ══════════════════════════════════════
   FORMS
══════════════════════════════════════ */
.form-label { font-size: .8rem; font-weight: 700; color: var(--t2); margin-bottom: .35rem; }
.form-control, .form-select {
    font-size: .84rem;
    border: 1.5px solid var(--line2);
    border-radius: 9px;
    padding: .5rem .85rem;
    background: var(--s1);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3.5px rgba(106,61,232,.13);
    background: var(--card);
    outline: none;
}
.form-control-sm, .form-select-sm { font-size: .8rem; padding: .32rem .65rem; }
.input-group-text {
    background: var(--page); border-color: var(--line2);
    border-radius: 9px; font-size: .84rem; font-weight: 600; color: var(--t2);
}
.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) { border-start-start-radius: 0; border-end-start-radius: 0; }
.input-group > .input-group-text:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn { font-size: .83rem; font-weight: 600; border-radius: 9px; transition: all .14s; }
.btn:active { transform: scale(.97) !important; }
.btn-sm { font-size: .77rem; padding: .3rem .75rem; }
.btn-primary {
    background: linear-gradient(135deg, #6a3de8 0%, #5e56e8 100%);
    border-color: #6a3de8;
    box-shadow: 0 2px 8px rgba(106,61,232,.28);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #4a25b8 0%, #6a3de8 100%);
    border-color: #4a25b8;
    box-shadow: 0 4px 12px rgba(106,61,232,.36);
    transform: translateY(-1px);
}
.btn-outline-primary:hover, .btn-outline-secondary:hover,
.btn-outline-danger:hover, .btn-outline-success:hover,
.btn-outline-warning:hover { transform: translateY(-1px); box-shadow: var(--shadow-xs); }
.btn-xs { font-size: .72rem; padding: .22rem .55rem; border-radius: 6px; }

/* ══════════════════════════════════════
   LANG SWITCH
══════════════════════════════════════ */
.lang-switch {
    display: flex; gap: 3px;
    background: var(--s2); border-radius: 9px; padding: 3px;
}
.lang-switch a {
    font-size: .72rem; font-weight: 700;
    padding: .24rem .68rem; border-radius: 7px;
    text-decoration: none; color: var(--t3);
    transition: all .13s;
}
.lang-switch a.active {
    background: var(--primary); color: #fff;
    box-shadow: 0 2px 6px rgba(106,61,232,.3);
}

/* ══════════════════════════════════════
   MOBILE / OVERLAY
══════════════════════════════════════ */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.48);
    backdrop-filter: blur(2px);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(calc(-100% - 24px)); }
    [dir="rtl"] .sidebar { transform: translateX(calc(100% + 24px)); }
    [dir="rtl"] .sidebar.open, [dir="ltr"] .sidebar.open { transform: translateX(0); }
    .sidebar.open { transform: translateX(0); }
        .sidebar-toggle { display: flex !important; }
    .page-body { padding: 1rem var(--sidebar-gap); }
    .main-wrapper { margin-inline-start: 0; }
}
.sidebar-toggle { display: none; }

/* ══════════════════════════════════════
   PRINT
══════════════════════════════════════ */
@media print {
    .sidebar, .topbar, .no-print, .filter-card { display: none !important; }
    .main-wrapper { margin: 0 !important; }
    .page-body { padding: 0; }
    .table-card, .chart-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ══════════════════════════════════════
   RTL TWEAKS
══════════════════════════════════════ */
[dir="rtl"] .table-card .table thead th,
[dir="rtl"] .table-card .table tbody td { text-align: right; }
[dir="rtl"] .kpi-card::before { border-radius: 0 var(--radius-xl) var(--radius-xl) 0; }

/* ── KPI extras ── */
.kpi-note { font-size: .72rem; color: var(--t4); margin-top: .35rem; font-weight: 600; }
.kpi-note a { color: inherit; text-decoration: underline dotted; }
.kpi-note a:hover { color: var(--primary); }
.kpi-mini-bar { height: 4px; background: var(--s2); border-radius: 4px; margin-top: .55rem; overflow: hidden; }
.kpi-mini-bar i { display: block; height: 100%; background: var(--kpi-accent); border-radius: 4px; transition: width .5s ease; }
.kpi-value.is-money { font-size: 1.35rem; white-space: nowrap; }

/* ── Toolbar ── */
.ll-toolbar {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-xl);
    padding: .6rem .7rem; box-shadow: var(--shadow-xs); margin-bottom: 1rem;
}
.ll-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.ll-row + .ll-row { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--s2); }
.ll-search { position: relative; flex: 1 1 240px; }
.ll-search > i { position: absolute; inset-inline-start: .85rem; top: 50%; transform: translateY(-50%); color: var(--t4); }
.ll-search input {
    width: 100%; border: 1px solid transparent; background: var(--page); border-radius: 12px;
    padding: .5rem 2.4rem; font-size: .86rem; transition: border-color .15s, background .15s;
}
.ll-search input:focus { outline: none; background: var(--card); border-color: var(--primary-l); box-shadow: 0 0 0 3px rgba(106,61,232,.12); }
.ll-search kbd {
    position: absolute; inset-inline-end: .7rem; top: 50%; transform: translateY(-50%);
    background: var(--card); color: var(--t4); border: 1px solid var(--line); font-size: .68rem; padding: .05rem .4rem; box-shadow: none;
}
.ll-seg { display: inline-flex; flex-wrap: wrap; background: var(--page); border-radius: 12px; padding: 3px; gap: 2px; }
.ll-seg button {
    border: 0; background: none; border-radius: 9px; padding: .32rem .75rem; white-space: nowrap;
    font-size: .78rem; font-weight: 700; color: var(--t3); display: inline-flex; align-items: center; gap: .35rem;
}
.ll-seg button:hover { color: var(--t2); }
.ll-seg button .n { font-size: .68rem; background: var(--line); color: var(--t2); border-radius: 10px; padding: 0 .4rem; }
.ll-seg button.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-xs); }
.ll-seg button.active .n { background: var(--soft); color: var(--primary); }
.ll-seg button.is-danger.active { color: #dc2626; }
.ll-seg button.is-danger.active .n { background: #fee2e2; color: #dc2626; }

.ll-field { display: inline-flex; align-items: center; gap: .4rem; font-size: .74rem; font-weight: 700; color: var(--t4); }
.ll-field .form-select, .ll-field .form-control {
    border-color: transparent; background-color: var(--page); border-radius: 10px;
    font-size: .78rem; font-weight: 600; color: var(--t2); width: auto; max-width: 190px;
}
.ll-field .form-select.has-value, .ll-field .form-control.has-value { background-color: var(--soft); color: var(--primary); }
.ll-clear {
    border: 0; background: none; font-size: .76rem; font-weight: 700; color: var(--t4);
    margin-inline-start: auto; text-decoration: none; white-space: nowrap;
}
.ll-clear:hover { color: #dc2626; }

/* ── Refresh state ── */
#liveRegion { transition: opacity .15s; }
#liveRegion.is-loading { opacity: .5; pointer-events: none; }

/* ── Table bits ── */
.ll-title { font-weight: 700; color: var(--t1); text-decoration: none; }
.ll-title:hover { color: var(--primary); }
.ll-sub { font-size: .74rem; color: var(--t4); margin-top: 1px; }
.ll-sub a { color: var(--t3); text-decoration: none; }
.ll-sub a:hover { color: var(--primary); }
.ll-num { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ll-avatar {
    width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: .76rem;
    background: linear-gradient(135deg, var(--ll-accent), color-mix(in srgb, var(--ll-accent) 60%, #171a3a));
}
.ll-usage { min-width: 150px; }
.ll-bar { height: 6px; background: var(--s2); border-radius: 6px; overflow: hidden; }
.ll-bar i { display: block; height: 100%; border-radius: 6px; background: #10b981; transition: width .6s ease; }
.ll-bar.is-warn i { background: #f59e0b; }
.ll-bar.is-danger i { background: #ef4444; }
.ll-bar-meta { display: flex; justify-content: space-between; gap: .5rem; font-size: .7rem; color: var(--t4); margin-top: .3rem; }
.ll-tag {
    display: inline-flex; align-items: center; gap: .25rem; font-size: .66rem; font-weight: 700;
    border-radius: 20px; padding: .08rem .5rem; background: var(--s2); color: var(--t2); vertical-align: middle;
}
.ll-tag.is-danger { background: #fee2e2; color: #b91c1c; }
.ll-tag.is-warn { background: #fef3c7; color: #92400e; }
.ll-tag.is-info { background: #e0f2fe; color: #0c4a6e; }
tr.is-closed .ll-title, tr.is-closed .ll-num { opacity: .6; }
.ll-more {
    border: 0; background: none; width: 32px; height: 32px; border-radius: 9px; color: var(--t4);
    display: inline-flex; align-items: center; justify-content: center;
}
.ll-more:hover, .ll-more[aria-expanded="true"] { background: var(--s2); color: var(--t2); }
.table-card .dropdown-menu { font-size: .84rem; border-radius: 12px; border-color: var(--line); padding: .35rem; }
.table-card .dropdown-item { border-radius: 8px; padding: .4rem .7rem; }
.ll-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; }
.ll-sort:hover, .ll-sort.active { color: var(--primary); }
.ll-status { border: 0; cursor: pointer; }
.ll-status::after { margin-inline-start: .35em; vertical-align: .1em; }

/* ── Topbar back link ── */
.topbar-back {
    width: 34px; height: 34px; border-radius: 10px; background: var(--page); color: var(--t2); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; text-decoration: none; transition: background .13s, color .13s;
}
.topbar-back:hover { background: var(--soft); color: var(--primary); }

/* ── Forms ── */
.form-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm); padding: 1.4rem 1.5rem;
}
.form-section {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--t3);
    display: flex; align-items: center; gap: .4rem; padding-bottom: .55rem; border-bottom: 1px solid var(--s2);
}
.form-section i { color: var(--primary); font-size: .9rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding-top: 1rem; margin-top: .3rem; border-top: 1px solid var(--s2); }
.req { color: #dc2626; }
.form-text { font-size: .74rem; color: var(--t4); }
.tip-card { border-inline-start: 4px solid var(--tip-accent, var(--primary)); }
.tip-card .tip-title { font-weight: 800; font-size: .88rem; display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.tip-card .tip-title i { color: var(--tip-accent, var(--primary)); font-size: 1.05rem; }
.tip-card ol, .tip-card ul { font-size: .8rem; color: var(--t3); padding-inline-start: 1.1rem; margin: 0; line-height: 1.9; }

/* ── Detail rows ── */
.dl-rows { margin: 0; }
.dl-rows > div {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .85rem;
}
.dl-rows > div:last-child { border-bottom: 0; padding-bottom: 0; }
.dl-rows dt { color: var(--t3); font-weight: 600; white-space: nowrap; }
.dl-rows dd { margin: 0; font-weight: 600; text-align: end; min-width: 0; overflow-wrap: anywhere; }
.dl-rows dd a { text-decoration: none; }

/* ── Hero header on detail pages ── */
.hero-card {
    display: flex; align-items: center; flex-wrap: wrap; gap: 1rem 1.4rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-xl);
    padding: 1.1rem 1.3rem; box-shadow: var(--shadow-sm); margin-bottom: 1rem;
}
.hero-card .ll-avatar { width: 52px; height: 52px; border-radius: 15px; font-size: 1rem; }
.hero-title { font-size: 1.1rem; font-weight: 800; color: var(--t1); line-height: 1.25; }
.hero-meta { font-size: .78rem; color: var(--t3); display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin-top: .2rem; }
.hero-meta a { color: inherit; text-decoration: none; }
.hero-meta a:hover { color: var(--primary); }
.hero-amount { font-size: 1.6rem; font-weight: 800; line-height: 1.1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hero-amount small { display: block; font-size: .68rem; font-weight: 700; color: var(--t4); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .2rem; }

/* ── Upload zone ── */
.upload-zone {
    border: 2px dashed var(--line2); border-radius: var(--radius-lg); padding: 1.4rem 1rem; text-align: center;
    cursor: pointer; color: var(--t3); transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.is-over { border-color: var(--primary-l); background: var(--s1); }
.upload-zone i { font-size: 1.7rem; color: var(--t4); display: block; margin-bottom: .3rem; }
.upload-zone b { display: block; font-size: .84rem; color: var(--t2); }
.upload-zone span { font-size: .74rem; }
.upload-file {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem;
    background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius-md);
}
.upload-file img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; }
.upload-file > i { font-size: 1.5rem; color: #16a34a; }
.upload-file .name { flex: 1; min-width: 0; font-size: .8rem; font-weight: 700; color: #166534; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file .name small { display: block; font-weight: 600; color: var(--t3); }

/* ── Receipt preview ── */
.rc-btn {
    border: 0; background: #ecfdf5; color: #047857; border-radius: 8px; padding: .22rem .55rem;
    font-size: .72rem; font-weight: 700; display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap;
}
.rc-btn:hover { background: #d1fae5; }
.rc-missing { color: var(--line2); font-size: .78rem; white-space: nowrap; }
.rc-missing:hover { color: var(--primary); }
.rc-body { background: var(--s2); min-height: 300px; display: flex; align-items: center; justify-content: center; }
.rc-body img { max-width: 100%; max-height: 75vh; }
.rc-body iframe { width: 100%; height: 75vh; border: 0; }
.pm-cell { font-size: .8rem; color: var(--t2); white-space: nowrap; }
.pm-cell i { color: var(--t4); margin-inline-end: .3rem; }

/* ── Things that need attention ── */
.attn { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.attn a {
    display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; font-size: .8rem; font-weight: 700;
    border-radius: 30px; padding: .4rem .9rem; background: var(--card); border: 1px solid var(--line); color: var(--t2);
    box-shadow: var(--shadow-xs); transition: transform .13s, box-shadow .13s;
}
.attn a:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.attn a i, .attn a b { color: var(--attn, #d97706); }
.alert-danger { background: linear-gradient(to right, #fee2e2, #fef2f2); color: #991b1b; border-inline-start: 4px solid #ef4444; }
.alert-danger ul { margin: .3rem 0 0; padding-inline-start: 1.1rem; }

/* ── Claude voice/chat assistant (partials/assistant) ── */
/* ── Claude assistant ── */
.pj-ai {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-xl, 18px); box-shadow: var(--shadow-sm);
    padding: 1rem 1.15rem; margin-bottom: 1rem; position: relative; overflow: hidden;
}
.pj-ai::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, #6a3de8, #a855f7, #8259ee); }
.pj-ai-head { display: flex; align-items: center; gap: .65rem; margin-bottom: .7rem; }
.pj-ai-head b { display: block; font-size: .9rem; color: var(--t1); }
.pj-ai-head small { font-size: .74rem; color: var(--t3); }
.pj-ai-badge { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-size: 1rem; flex-shrink: 0;
    background: linear-gradient(135deg, #6a3de8 0%, #a855f7 100%); box-shadow: 0 4px 12px rgba(168,85,247,.3); }
.pj-ai-box { display: flex; align-items: flex-end; gap: .5rem; background: var(--s1); border: 1.5px solid var(--line); border-radius: 14px; padding: .45rem .5rem .45rem .8rem; transition: border-color .15s, box-shadow .15s; }
.pj-ai-box:focus-within { border-color: #c4b0f7; box-shadow: 0 0 0 3.5px rgba(106,61,232,.12); background: var(--card); }
.pj-ai-box textarea { flex: 1; border: 0; background: transparent; resize: vertical; min-height: 44px; font-size: .88rem; outline: none; padding: .3rem 0; }
.pj-ai-actions { display: flex; align-items: center; gap: .35rem; flex-shrink: 0; }
.pj-ai-mic { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--soft); color: var(--brand-ink); display: grid; place-items: center; transition: background .15s, color .15s; }
.pj-ai-mic:hover { background: var(--soft2); }
.pj-ai-mic.is-on { background: #ef4444; color: #fff; animation: pjMic 1.2s ease-in-out infinite; }
@keyframes pjMic { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } }
.pj-ai-hints { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.pj-ai-hint { border: 1px dashed var(--line2); background: var(--card); color: var(--t2); border-radius: 20px; padding: .2rem .7rem; font-size: .72rem; font-weight: 600; text-align: start; }
.pj-ai-hint:hover { border-color: #c4b0f7; color: var(--brand-ink); background: var(--s1); }
.pj-ai-status { margin-top: .6rem; font-size: .8rem; color: var(--brand-ink); font-weight: 600; display: flex; align-items: center; }
.pj-ai-status.is-error { color: #b91c1c; }
.pj-ai-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; margin-inline-end: .5rem; animation: pjMic 1.2s infinite; }
.pj-ai-status.is-question { color: var(--t1); background: var(--soft); border: 1px solid var(--line2); border-radius: 10px; padding: .5rem .7rem; white-space: pre-line; }
.pj-ai-fab {
    position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 1040; width: 56px; height: 56px; border-radius: 50%; border: 0;
    color: #fff; font-size: 1.35rem; display: grid; place-items: center; cursor: pointer;
    background: linear-gradient(135deg, #6a3de8 0%, #a855f7 100%); box-shadow: 0 10px 28px rgba(168,85,247,.45);
    transition: transform .15s;
}
.pj-ai-fab:hover { transform: scale(1.06); }
.pj-ai.is-floating {
    position: fixed; bottom: 90px; inset-inline-end: 22px; z-index: 1041; width: min(440px, calc(100vw - 32px)); margin: 0;
    box-shadow: 0 20px 50px rgba(15,23,42,.25);
}
@media (max-width: 575.98px) { .pj-ai-fab { bottom: 16px; inset-inline-end: 16px; } .pj-ai.is-floating { inset-inline-end: 16px; bottom: 84px; } }

/* ── Bootstrap, in the logo's colours ── */
.btn-outline-primary { --bs-btn-color: #5a2fd6; --bs-btn-border-color: #c4b0f7; --bs-btn-hover-bg: #6a3de8; --bs-btn-hover-border-color: #6a3de8; --bs-btn-active-bg: #5a2fd6; --bs-btn-active-border-color: #5a2fd6; }
.form-check-input:checked { background-color: #6a3de8; border-color: #6a3de8; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: #c4b0f7; box-shadow: 0 0 0 .2rem rgba(106,61,232,.12); }
.dropdown-item.active, .dropdown-item:active { background-color: #6a3de8; }
.pagination { --bs-pagination-color: #5a2fd6; --bs-pagination-active-bg: #6a3de8; --bs-pagination-active-border-color: #6a3de8; }
.nav-pills { --bs-nav-pills-link-active-bg: #6a3de8; }

/* ══════════════════════════════════════
   DARK MODE
══════════════════════════════════════ */
.theme-toggle { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--t2); display: grid; place-items: center; }
.theme-toggle:hover { background: var(--soft); color: var(--brand-ink); }
.theme-toggle .bi-sun-fill { display: none; }
[data-theme="dark"] .theme-toggle .bi-sun-fill { display: inline; }
[data-theme="dark"] .theme-toggle .bi-moon-stars-fill { display: none; }

[data-theme="dark"] {
    --card: #1c1e3a; --page: #14152b; --s1: #23254a; --s2: #2a2c52; --soft: #2d2858; --soft2: #393170;
    --t1: #eceaf7; --t2: #c5c6dc; --t3: #a4a6c2; --t4: #868aa8; --line: #2e3056; --line2: #3c3e68; --brand-ink: #b9a3f8;
    --bs-body-bg: #14152b; --bs-body-color: #c5c6dc; --bs-border-color: #2e3056; --bs-secondary-color: #a4a6c2; --bs-tertiary-bg: #23254a; --bs-secondary-bg: #23254a;
    --bs-link-color: #b9a3f8; --bs-link-color-rgb: 185,163,248; --bs-link-hover-color: #d2c4fb; --bs-link-hover-color-rgb: 210,196,251;
    --bs-heading-color: #eceaf7;
    --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0,0,0,.25); --shadow-md: 0 4px 16px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.35);
}
[data-theme="dark"] body { background: var(--page); color: var(--t2); }
[data-theme="dark"] .bg-white, [data-theme="dark"] .bg-light { background-color: var(--s1) !important; }
[data-theme="dark"] .text-dark { color: var(--t1) !important; }
[data-theme="dark"] .text-muted { color: var(--t3) !important; }
[data-theme="dark"] .btn-light { --bs-btn-bg: var(--s1); --bs-btn-border-color: var(--line); --bs-btn-color: var(--t2); --bs-btn-hover-bg: var(--s2); --bs-btn-hover-border-color: var(--line2); --bs-btn-hover-color: var(--t1); }
[data-theme="dark"] .btn-outline-primary { --bs-btn-color: #b9a3f8; --bs-btn-border-color: #4f4590; }
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select { background-color: var(--s1); border-color: var(--line2); color: var(--t1); }
[data-theme="dark"] .form-control::placeholder, [data-theme="dark"] textarea::placeholder { color: var(--t4); }
[data-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--t2); --bs-table-border-color: var(--line); --bs-table-hover-bg: var(--s1); --bs-table-hover-color: var(--t1); }
[data-theme="dark"] .modal-content, [data-theme="dark"] .dropdown-menu, [data-theme="dark"] .card { background-color: var(--card); border-color: var(--line); color: var(--t2); }
[data-theme="dark"] .dropdown-item { color: var(--t2); }
[data-theme="dark"] .dropdown-item:hover { background: var(--s2); color: var(--t1); }
[data-theme="dark"] .sidebar-user:hover, [data-theme="dark"] .sidebar-nav .nav-link:hover { background: var(--s1); }
[data-theme="dark"] .sidebar { box-shadow: none; }
[data-theme="dark"] .sidebar-nav .nav-link.active i { color: #b9a3f8; }
[data-theme="dark"] .alert-success, [data-theme="dark"] .alert-danger, [data-theme="dark"] .alert-warning, [data-theme="dark"] .alert-info { --bs-alert-bg: var(--s1); --bs-alert-border-color: var(--line2); --bs-alert-color: var(--t1); }
/* The project diagram has its own dark look: keep its colours as they are in light mode */
[data-theme="dark"] .pj-flow { --t1: #171a3a; --t2: #475569; --t3: #64748b; --t4: #94a3b8; --line: #ebe8f4; --line2: #d6d0e6; --s1: #f8f6ff; --s2: #f1f5f9; --card: #fff; }
/* Pale status tints would glare on a dark page */
[data-theme="dark"] .kpi-icon, [data-theme="dark"] .tdy-pill, [data-theme="dark"] [class*="status-"] { filter: brightness(.85) saturate(.9); }

/* Keyboard focus is always visible */
a:focus-visible, button:focus-visible, .btn:focus-visible, [tabindex]:focus-visible, summary:focus-visible { outline: 3px solid #c4b0f7; outline-offset: 2px; }

/* File inputs shown in the page's language */
.file-pick-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-pick { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 38px; padding: .3rem .4rem; border: 1px solid var(--line2, #d6d0e6); border-radius: 10px; background: var(--card); cursor: pointer; margin: 0; }
.file-pick.is-sm { min-height: 31px; padding: .2rem .3rem; font-size: .82rem; }
.file-pick-btn { display: inline-flex; align-items: center; gap: .35rem; flex: none; padding: .2rem .7rem; border-radius: 8px; background: var(--soft, #f3effe); color: var(--brand-ink, #5a2fd6); font-weight: 700; font-size: .82rem; }
.file-pick-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t3); font-size: .82rem; }
.file-pick-input:focus-visible + .file-pick { outline: 3px solid #c4b0f7; outline-offset: 2px; }