/* ════════════════════════════════════════════════════════════════
   السجل (view-transactions) — modern banking-app card list (mobile)
   Day-grouped, tap-to-expand for edit/delete.
   ════════════════════════════════════════════════════════════════ */
.ledger-mobile { display: none; } 
/* The new ledger filter bar is structured (no inline styles), so style it
   universally — visible on desktop and mobile. */
.ledger-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 8px;
    margin-bottom: 14px;
}
.ledger-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.ledger-filter--full { grid-column: 1 / -1; }
/* Wide screens: the three selects and the search share one row. */
@media (min-width: 1024px) {
    .ledger-filters { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.6fr); }
    .ledger-filter--full { grid-column: auto; }
}
.ledger-filter__label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.2px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.ledger-filter__label i {
    font-size: 0.7rem;
    color: var(--text-faint);
}
.ledger-filter__select,
.ledger-filter__input {
    width: 100%;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(15,23,42,0.03);
    box-sizing: border-box;
}
/* Native select on iOS/Android always shows its own chevron — drawing our own
   on top inevitably collides with the value. Cleaner approach: keep the native
   chevron, just give the select breathing room and do not paint a custom one. */
.ledger-filter__select {
    appearance: auto;            /* let the OS draw the chevron natively */
    -webkit-appearance: menulist; /* iOS Safari */
    padding: 10px 14px;
    cursor: pointer;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    background-image: none;       }
.ledger-filter__input::placeholder { color: var(--tx-faint); font-weight: 600; }
/* Custom date range — its own panel below the filter grid so the native
   <input type="date"> never gets squeezed inside a 50% column. */
.ledger-range-panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}
.ledger-range-panel__header {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-strong);
    margin-bottom: 10px;
}
.ledger-range-panel__header i {
    font-size: 0.78rem;
    color: var(--text-faint);
}
.ledger-range-panel__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ledger-range-panel__field {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 11px;
    padding: 4px 12px 4px 4px;
    cursor: pointer;
}
.ledger-range-panel__field-label {
    flex-shrink: 0;
    min-width: 32px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-strong);
    text-align: center;
}
.ledger-range-panel__field input[type="date"] {
    flex: 1;
    min-width: 0;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 9px;
    padding: 9px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: inherit;
    direction: ltr;
    box-sizing: border-box;
}
/* Old total/count chips — never shown anymore */
.ledger-filter__total,
.ledger-filter__count { display: none; }

@media (max-width: 768px) {
    /* Hide the desktop table on mobile */
    #view-transactions .tx-table-desktop { display: none !important; }
    .ledger-mobile { display: block; padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }

    /* On mobile, stack labelled filters vertically. The "الفترة" select gets
       full width because its values are the longest, then categories+wallet in
       a 2-column grid, then search full width. */
    .ledger-filters {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .ledger-filter:nth-child(1) { grid-column: 1 / -1; } /* الفترة */
    .ledger-filter:nth-child(2),
    .ledger-filter:nth-child(3) { grid-column: span 1; } /* البند / الحساب */
    .ledger-filter--full { grid-column: 1 / -1; }

    /* Hide the legacy total/count chips on mobile too */
    #view-transactions #ledger-month-total,
    #view-transactions #ledger-filter-count { display: none !important; }
    /* The desktop export button bar has no purpose on mobile (FAB replaces it) */
    #view-transactions .tx-export-desktop { display: none !important; }

    /* ─── Hero stats card — clean white to match the rest of the page ─── */
    .ledger-stats {
        background: var(--sf-card);
        color: var(--tx-main);
        border: 1px solid var(--ln);
        border-radius: var(--radius-md);
        padding: var(--sp-3);
        margin-bottom: var(--sp-2);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--sp-3);
        box-shadow: var(--el-1);
    }
    .ledger-stats__label {
        font-size: var(--fs-xs);
        font-weight: 800;
        color: var(--tx-muted);
        letter-spacing: 0.2px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }
    .ledger-stats__label::before {
        content: '';
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--money-out);
        flex-shrink: 0;
    }
    .ledger-stats__amount-row {
        display: flex;
        align-items: baseline;
        gap: 4px;
        margin-top: 6px;
    }
    .ledger-stats__amount {
        font-size: var(--fs-xl);
        font-weight: 800;
        line-height: 1;
        color: var(--money-out);
    }
    .ledger-stats__cur {
        font-size: var(--fs-xs);
        color: var(--tx-faint);
        font-weight: 700;
        letter-spacing: 0.4px;
    }
    .ledger-stats__count {
        background: var(--sf-sunken);
        border: 1px solid var(--ln);
        border-radius: var(--radius-sm);
        padding: var(--sp-1) var(--sp-3);
        text-align: center;
        flex-shrink: 0;
        margin-inline-start: auto;
    }
    /* Excel export lives in the summary card (replaces the floating green button) */
    .ledger-stats__export {
        flex-shrink: 0;
        width: var(--tap); height: var(--tap);
        display: inline-flex; align-items: center; justify-content: center;
        border: 1px solid var(--ln);
        border-radius: var(--radius-sm);
        background: var(--sf-card);
        color: var(--tx-main);
        font-size: 1rem;
        cursor: pointer;
        transition: transform var(--mo-fast) var(--ease);
    }
    .ledger-stats__export:active { transform: scale(0.97); }
    .ledger-stats__export:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
    .ledger-stats__count-num {
        display: block;
        font-size: 1.2rem;
        font-weight: 800;
        line-height: 1;
        color: var(--tx-main);
    }
    .ledger-stats__count-label {
        display: block;
        font-size: var(--fs-xs);
        color: var(--tx-muted);
        font-weight: 700;
        margin-top: 3px;
        letter-spacing: 0.3px;
    }

    /* ─── Active filter chips (clearable) ─── */
    .ledger-active-chips {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
        margin-bottom: 10px;
    }
    .ledger-active-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: var(--c-primary-soft);
        color: var(--c-primary);
        border: 1px solid var(--c-primary-line);
        border-radius: 999px;
        padding: 4px 12px;
        font-family: inherit;
        font-size: 0.72rem;
        font-weight: 800;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .ledger-active-chip i {
        font-size: 0.65rem;
        opacity: 0.7;
    }
    .ledger-active-chip:active { transform: scale(0.95); }

    /* ─── Day group ─── */
    .ledger-day {
        margin-bottom: var(--sp-2);
    }
    .ledger-day__header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--sp-1);
        position: sticky;
        top: 0;
        background: var(--sf-sunken);
        z-index: 2;
    }
    .ledger-day__label {
        font-size: var(--fs-sm);
        font-weight: 800;
        color: var(--tx-main);
        letter-spacing: 0.1px;
    }
    .ledger-day__total {
        font-size: var(--fs-xs);
        font-weight: 800;
        color: var(--tx-muted);
        background: var(--sf-card);
        border: 1px solid var(--ln);
        border-radius: 999px;
        padding: 3px 10px;
    }
    .ledger-day__list {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
}

