/* 43-v2-ledger.css — the new interface's العمليات (body.ui-v2): السجل (view-transactions) and التحليل (view-spending).
   Plan: docs/plans/2026-11-ui-redesign.md (phase 3) · design: prototype #Ledger, #Analysis · JS: features/ledger/v2-log*.js,
   features/ledger/v2-tx-sheet.js, features/spending/v2-analysis*.js.
   Uses the shared components of 40-v2-base.css (.v2-seg, .v2-chips, .v2-card, .v2-row, .v2-tile, .v2-amt, .v2-btn, …);
   only this screen's own parts are defined here. Every rule is scoped to .ui-v2, except hiding the v2 parts in classic. */

/* ── Classic: the v2 parts stay hidden ── */
.v2-ops-head, .v2-ops { display: none; }

/* ── v2: the classic list, table, totals and spending page give way to the new screens ── */
.ui-v2 .v2-ops-head { display: flex; align-items: center; gap: 8px; padding: 4px 0 12px; }
.ui-v2 .v2-ops {
    display: block; color: var(--c-text);
    /* this screen's chart colours (prototype #Analysis): bars, today, the comfortable line, the «above it» text */
    --v2-bar: var(--st-neutral); --v2-today: #fbbf24; --v2-pace: var(--c-warning); --v2-warn-text: #92400e;
}
.ui-v2 .v2-ops-head__seg { flex: 1; min-width: 0; }
.ui-v2 #view-transactions > .tx-export-desktop,
.ui-v2 #view-transactions > .tx-table-desktop,
.ui-v2 #ledger-mobile-cards,
.ui-v2 #spending-content { display: none !important; }
.ui-v2 #view-transactions .page-fab,
.ui-v2 #view-transactions .fab { display: none !important; }
.ui-v2 #view-transactions .ledger-filters { display: none; }
.ui-v2 #view-transactions:not(.v2-log--filter) #ledger-custom-range { display: none !important; }
.ui-v2 .ledger-filter__total, .ui-v2 .ledger-filter__count { display: none !important; }
/* The search button opens only the search field; the filter button the period, category and account. */
.ui-v2 #view-transactions.v2-log--search .ledger-filters,
.ui-v2 #view-transactions.v2-log--filter .ledger-filters {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
    margin: 0 0 6px; padding: 12px; border-radius: 18px; background: var(--c-surface);
}
.ui-v2 #view-transactions.v2-log--search .ledger-filter:not(.ledger-filter--full),
.ui-v2 #view-transactions.v2-log--filter .ledger-filter--full { display: none; }
.ui-v2 #view-transactions .v2-icon-btn[aria-expanded="true"] { background: var(--c-primary-soft); color: var(--c-primary); }

/* Phones: the prototype's 16px side margin (the page itself gives 6px). */
@media (max-width: 768px) {
    .ui-v2 #view-transactions.active, .ui-v2 #view-spending.active { padding-inline: 10px; }
    .ui-v2 .v2-ops-head { padding-top: 10px; }
}
@media (min-width: 769px) {
    .ui-v2 .v2-ops-head, .ui-v2 .v2-ops, .ui-v2 #view-transactions .ledger-filters, .ui-v2 #ledger-custom-range {
        max-width: 720px; margin-inline: auto;
    }
}

/* ── Shared bits of both screens ── */
.ui-v2 .v2-ops-cur { font-size: 11.5px; font-weight: 500; color: var(--c-text-muted); margin-inline-start: 3px; }
/* Mixed Arabic/Latin names: plaintext so the ellipsis clips their end; each sits at the row's start
   (fit-content in a column that aligns to the start), since plaintext would flip text-align for a Latin name. */
.ui-v2 .v2-bidi { unicode-bidi: plaintext; max-width: 100%; }
.ui-v2 .v2-ops .v2-row__text, .ui-v2 .v2-tx-sheet .v2-row__text, .ui-v2 .v2-an-place { display: flex; flex-direction: column; align-items: flex-start; }
.ui-v2 .v2-ops-chips { padding: 14px 0 4px; }
.ui-v2 .v2-ops-chips .v2-chip i { margin-inline-end: 2px; }
.ui-v2 .v2-ops-link {
    display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0; border: 0; background: none;
    color: var(--c-primary); font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.ui-v2 .v2-ops-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 28px 20px; margin-top: 16px; }
.ui-v2 .v2-ops-empty__ic { font-size: 26px; color: var(--c-text-muted); margin-bottom: 4px; }
.ui-v2 .v2-ops-empty__title { margin: 0; font-size: 15px; font-weight: 700; color: var(--c-text); }
.ui-v2 .v2-ops-empty__sub { margin: 0 0 6px; font-size: 13px; color: var(--c-text-muted); line-height: 1.6; }
.ui-v2 .v2-ops-empty .v2-btn { min-width: 160px; }

/* ── السجل: summary, caption, active filters ── */
.ui-v2 .v2-ops-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ui-v2 .v2-ops-sum__box { min-width: 0; background: var(--c-surface); border-radius: 18px; padding: 12px; }
.ui-v2 .v2-ops-sum__box small { display: block; font-size: 12px; font-weight: 500; color: var(--c-text-muted); }
.ui-v2 .v2-ops-sum__box b { display: block; margin-top: 2px; font-size: clamp(14px, 4.4vw, 17px); overflow: hidden; text-overflow: ellipsis; }
.ui-v2 .v2-ops-cap { margin: 8px 4px 0; font-size: 12.5px; line-height: 1.5; color: var(--c-text-muted); }
.ui-v2 .v2-ops-active { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ui-v2 .v2-ops-active__pill { min-height: 32px; max-width: 100%; border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; background: var(--c-primary-soft); color: var(--c-primary); }
.ui-v2 .v2-ops-active__pill span { overflow: hidden; text-overflow: ellipsis; }

/* ── السجل: day groups and rows ── */
.ui-v2 .v2-log-day { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 20px 4px 8px; font-size: 13.5px; font-weight: 700; }
.ui-v2 .v2-log-day__name { min-width: 0; color: var(--c-text-muted); }
.ui-v2 .v2-log-day__name b { color: var(--c-text); }
.ui-v2 .v2-log-day__tot { flex: none; font-size: 13px; font-weight: 600; color: var(--c-text-muted); }
.ui-v2 .v2-log-card { padding: 4px 16px; }
.ui-v2 .v2-log-card > .v2-row { min-height: 58px; padding: 8px 0; }
.ui-v2 .v2-log-tile { width: 38px; height: 38px; border-radius: 14px; background: var(--c-surface-2); color: var(--c-text); font-size: 17px; }
.ui-v2 .v2-log-tile--in { background: var(--c-success-soft); color: var(--amt-income); }
.ui-v2 .v2-log-tile--move { background: var(--money-move-soft); color: var(--amt-transfer); }
.ui-v2 .v2-log-row .v2-amt { font-size: 15.5px; }
.ui-v2 .v2-log-more { margin-top: 18px; }
.ui-v2 .v2-log-more .v2-btn { width: 100%; }

/* ── Detail sheet (inside #generic-modal) ── */
.ui-v2 .v2-tx-sheet__hero { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; }
.ui-v2 .v2-tx-sheet__name { display: block; font-size: 16px; font-weight: 700; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-v2 .v2-tx-sheet__amt { flex: none; font-size: 19px; }
.ui-v2 .v2-tx-sheet__rows { background: var(--c-surface-2); border-radius: 16px; padding: 4px 14px; margin-bottom: 14px; }
.ui-v2 .v2-tx-sheet__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; font-size: 14px; }
.ui-v2 .v2-tx-sheet__row + .v2-tx-sheet__row { border-top: 1px solid var(--c-border); }
.ui-v2 .v2-tx-sheet__row > span { flex: none; color: var(--c-text-muted); }
.ui-v2 .v2-tx-sheet__row > strong { min-width: 0; font-weight: 600; text-align: end; overflow-wrap: anywhere; }
.ui-v2 .v2-tx-sheet__msg { margin: -4px 0 14px; font-size: 13px; color: var(--c-text-muted); }
.ui-v2 .v2-tx-sheet__msg summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--c-primary); }
.ui-v2 .v2-tx-sheet__msg p { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--c-surface-2); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── التحليل: spend vs budget card and the daily bars ── */
.ui-v2 .v2-an-card { padding: 16px; margin-top: 12px; }
.ui-v2 .v2-an-k { font-size: 13px; font-weight: 500; color: var(--c-text-muted); }
.ui-v2 .v2-an-big { margin-top: 2px; font-size: var(--v2-fs-amount); font-weight: 700; line-height: 1.2; color: var(--c-text); }
.ui-v2 .v2-an-big .v2-ops-cur { font-size: 12px; margin-inline-start: 4px; }
.ui-v2 .v2-an-sub { font-size: 13px; color: var(--c-text-muted); line-height: 1.6; }
.ui-v2 .v2-an-sub b { color: var(--c-text); }
.ui-v2 .v2-an-sub .v2-amt--over, .ui-v2 .v2-an-sub .v2-amt--over b { color: var(--amt-over); }
.ui-v2 .v2-an-sub .v2-ops-link { min-height: 0; font-size: 13px; }
.ui-v2 .v2-an-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.ui-v2 .v2-an-duo__box { min-width: 0; border-radius: 14px; background: var(--c-surface-2); padding: 10px 12px; color: var(--c-text); }
.ui-v2 .v2-an-duo__box > small:first-child { display: block; font-size: 12px; color: var(--c-text-muted); }
.ui-v2 .v2-an-duo__box b { font-size: 17px; font-weight: 700; }
.ui-v2 .v2-an-duo__box.is-warn { background: var(--c-warning-soft); }
.ui-v2 .v2-an-duo__box.is-warn small, .ui-v2 .v2-an-duo__box.is-warn b, .ui-v2 .v2-an-duo__box.is-warn .v2-ops-cur { color: var(--v2-warn-text); }
.ui-v2 .v2-an-chart { position: relative; height: 132px; margin-top: 18px; display: flex; align-items: flex-end; gap: 3px; border-bottom: 1px solid var(--c-border); }
.ui-v2 .v2-an-bar-d { flex: 1 1 0; min-width: 0; border-radius: 4px 4px 1px 1px; background: var(--v2-bar); }
.ui-v2 .v2-an-bar-d.is-today { background: var(--v2-today); }
.ui-v2 .v2-an-bar-d.is-future { height: 4px; background: var(--c-surface-2); }
.ui-v2 .v2-an-pace { position: absolute; inset-inline: 0; border-top: 2px dashed var(--v2-pace); opacity: .7; pointer-events: none; }
.ui-v2 .v2-an-axis { position: relative; display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--c-text-muted); }
.ui-v2 .v2-an-axis__today { position: absolute; top: 0; transform: translateX(50%); white-space: nowrap; }
.ui-v2 .v2-an-leg { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 10px; font-size: 12px; color: var(--c-text-muted); }
.ui-v2 .v2-an-leg span { display: inline-flex; align-items: center; gap: 6px; }
.ui-v2 .v2-an-leg__line { display: inline-block; width: 18px; border-top: 2px dashed var(--v2-pace); }
.ui-v2 .v2-an-leg__today { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--v2-today); }

/* ── التحليل: insight card ── */
.ui-v2 .v2-an-ins { display: flex; gap: 12px; margin-top: 12px; padding: 16px 16px 8px; border-radius: 22px; background: var(--c-primary-soft); }
.ui-v2 .v2-an-ins .v2-tile { background: var(--c-surface); color: var(--c-primary); }
.ui-v2 .v2-an-ins p { margin: 0; font-size: 14px; line-height: 1.65; color: var(--c-text); }

/* ── التحليل: categories and top places ── */
.ui-v2 .v2-an-sh { align-items: baseline; margin: var(--v2-sp-sec) 4px var(--v2-sp-head); }
.ui-v2 .v2-an-sh__note { flex: none; font-size: 12.5px; color: var(--c-text-muted); }
.ui-v2 .v2-an-cats { padding: 4px 16px; }
.ui-v2 .v2-an-cats > .v2-row + .v2-row { border-top: 1px solid var(--c-border); }
.ui-v2 .v2-an-cat { min-height: 64px; padding: 11px 0; cursor: default; }
.ui-v2 button.v2-an-cat { cursor: pointer; }
.ui-v2 .v2-an-cat__top, .ui-v2 .v2-an-cat__bot { align-self: stretch; }
.ui-v2 .v2-an-cat__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.ui-v2 .v2-an-cat__top .v2-row__title { font-size: 14.5px; }
.ui-v2 .v2-an-cat__top strong { flex: none; font-size: 15px; font-weight: 700; }
.ui-v2 .v2-an-cat__bot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
/* The category's own budget: full = all of it spent; red once it is passed. */
.ui-v2 .v2-an-bar { display: block; align-self: stretch; height: 6px; margin-top: 8px; border-radius: var(--radius-pill); background: var(--c-surface-2); overflow: hidden; }
.ui-v2 .v2-an-bar > span { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--v2-bar); }
.ui-v2 .v2-an-bar > span.is-over { background: var(--amt-over); }
.ui-v2 .v2-an-amt { flex: none; white-space: nowrap; }
.ui-v2 .v2-an-of { font-size: 12px; font-weight: 500; color: var(--c-text-muted); }
.ui-v2 .v2-an-left { min-width: 0; font-size: 12.5px; color: var(--c-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-v2 .v2-an-left .num { color: var(--c-text); font-weight: 700; }
.ui-v2 .v2-an-left.is-over, .ui-v2 .v2-an-left.is-over .num { color: var(--amt-over); }
.ui-v2 .v2-an-ch { flex: none; min-width: 78px; text-align: end; font-size: 11.5px; font-weight: 600; color: var(--c-text-muted); }
.ui-v2 .v2-an-ch--up { color: var(--amt-over); }
.ui-v2 .v2-an-ch--dn { color: var(--amt-income); }
.ui-v2 .v2-an-places { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ui-v2 .v2-an-place { min-width: 0; background: var(--c-surface); border-radius: 18px; padding: 14px; }
.ui-v2 .v2-an-place b { display: block; font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-v2 .v2-an-place strong { display: block; margin-top: 6px; font-size: 18px; font-weight: 700; }
.ui-v2 .v2-an-place small { display: block; font-size: 12px; color: var(--c-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
