/* 40-v2-base.css — the new interface (body.ui-v2): shared components and the amount colour rule.
   Plan: docs/plans/2026-11-ui-redesign.md · design: docs/design/redesign-2026-11/prototype.html · rules: docs/DESIGN.md «New interface».
   Every rule here is scoped to .ui-v2 (or hides a v2-only element in classic), so the classic look does not move.
   Components (use these in phases 2–8, never a copy):
     .v2-page          a v2 section's padding        .v2-head / .v2-head__title   back button + page title (القائمة, sub-pages)
     .v2-card          white card, 22px radius       .v2-list + .v2-row           rows with a hairline between them
     .v2-tile          40px icon tile                .v2-row__title / __sub / __chev / .v2-row__end (amount or action)
     .v2-group-title   small heading above a card    .v2-sec-head                 section header: title, total, (+)
     .v2-add           the small round (+)           .v2-pill (--ok/--warn/--bad/--move/--new)  status pill
     .v2-seg           segmented switch (role=tablist, .is-on)        .v2-chips / .v2-chip (.is-on)  filter chips
     .v2-sheet         detail sheet (bottom sheet on phones) with .v2-sheet__head/__body/__actions
     .v2-field         label + input                 .v2-btn (--primary/--danger)  buttons
     .v2-icon-btn      44px icon button              .v2-badge                    count on an icon button
     .v2-amt (--in/--move/--over)   an amount; plain = expense (text colour, with its minus sign)
     .v2-mobile-only / .v2-desktop-only
   Tour anchors: mark what a guided-tour step points at with data-tour="…" (never a class name). */

/* ── Type scale and surfaces (v2). Sizes come from here, never a new px value in a page file:
      display 36 (اليوم's hero), amount 28 (a page's main amount), title 18, section 16, body 14.5, sub 12.
      The page is a shade darker than the cards and the bars, and cards carry a hairline ring, so card,
      page and bars read apart on a phone in daylight. ── */
.ui-v2 {
    --v2-fs-display: 36px; --v2-fs-amount: 28px; --v2-fs-title: 18px; --v2-fs-section: 16px;
    --v2-fs-body: 14.5px; --v2-fs-sub: 12px;
    --c-bg: #eef1f6; --bg-main: #eef1f6;
    /* Muted text a shade darker so it keeps AA (≥ 4.5:1) on the darker page too; the aliases resolved at
       :root are pointed at it again here. */
    --c-text-muted: #5b6779; --tx-muted: #5b6779; --tx-faint: #5b6779; --text-muted: #5b6779; --text-faint: #5b6779; --secondary: #5b6779;
    --v2-card-ring: 0 0 0 1px rgba(15,23,42,.05), 0 1px 2px rgba(15,23,42,.05);
    /* Spacing: the same three gaps on every page. sec = a card's end to the next section's title,
       head = a title to its card, card = card to card inside one section. */
    --v2-sp-sec: 28px; --v2-sp-head: 10px; --v2-sp-card: 12px;
}
body.ui-v2, .ui-v2 .main-content { background-color: var(--c-bg); }

/* ── Classic: v2-only parts stay hidden ── */
.v2-nav, .v2-side, .v2-today-top { display: none; }

/* ── Amount colours (phase 0 rule): expense = text colour with a minus; income green; transfer blue;
      red only for over-budget and errors. Existing expense amounts follow it under .ui-v2 by
      redefining --money-out on the components that show spending (resolved per surface, so the dark
      review / bank-SMS surfaces keep their light text). Over-budget, negative balances and debts keep red. ── */
.ui-v2 .lcard,
.ui-v2 .tx-amt,
.ui-v2 .ledger-stats,
.ui-v2 .brv-money--expense,
.ui-v2 .sav-hist__stat .is-out { --money-out: var(--amt-expense); }
.ui-v2 .sts-row__amt--out { color: var(--amt-expense); }

.ui-v2 .v2-amt { color: var(--amt-expense); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ui-v2 .v2-amt--in { color: var(--amt-income); }
.ui-v2 .v2-amt--move { color: var(--amt-transfer); }
.ui-v2 .v2-amt--over { color: var(--amt-over); }

/* ── Page and header ── */
.ui-v2 .v2-page { color: var(--c-text); }
.ui-v2 .v2-head { display: flex; align-items: center; gap: 10px; padding: 4px 0 6px; }
.ui-v2 .v2-head__title { flex: 1; min-width: 0; margin: 0; font-size: var(--v2-fs-title); font-weight: 700; line-height: 1.3; color: var(--c-text); }
.ui-v2 .v2-grow { flex: 1; min-width: 0; }

.ui-v2 .v2-icon-btn {
    position: relative; flex: none; width: 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center; border: 0; background: var(--c-surface); color: var(--c-text);
    box-shadow: var(--v2-card-ring);
    font: inherit; font-size: 17px; cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: transform var(--mo-fast) var(--ease-out);
}
.ui-v2 .v2-icon-btn:active { transform: scale(.94); }
/* In the app .native-only is display:flex !important (26-native-app.css), which pushed the icon to one side. */
html[data-platform="android"] body.ui-v2 .v2-icon-btn.native-only { display: grid !important; }
.ui-v2 .v2-icon-btn > i { line-height: 1; }
.ui-v2 .v2-badge {
    position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: var(--radius-pill); background: var(--c-danger); color: #fff;
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--c-surface);
}
.ui-v2 .v2-badge[hidden] { display: none; }

/* ── Cards and rows ── */
.ui-v2 .v2-card { background: var(--c-surface); border-radius: 20px; padding: 2px 16px; box-shadow: var(--v2-card-ring); }
.ui-v2 .v2-group-title { font-size: 13px; font-weight: 700; color: var(--c-text-muted); margin: var(--v2-sp-sec) 6px var(--v2-sp-head); line-height: 1.4; }
.ui-v2 .v2-row {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 0;
    border: 0; background: none; color: var(--c-text); font: inherit; text-align: start; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ui-v2 .v2-list > .v2-row + .v2-row { border-top: 1px solid var(--c-border); }
.ui-v2 .v2-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ui-v2 .v2-row__title { display: block; font-size: var(--v2-fs-body); font-weight: 600; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-v2 .v2-row__sub { display: block; font-size: var(--v2-fs-sub); color: var(--c-text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-v2 .v2-row__chev { flex: none; color: var(--c-text-muted); font-size: 14px; }
.ui-v2 .v2-row__end { flex: none; text-align: end; }
.ui-v2 .v2-tile { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--c-primary-soft); color: var(--c-primary); font-size: 16px; }

/* ── Section header with a total and (+) ── */
.ui-v2 .v2-sec-head { display: flex; align-items: center; gap: 8px; min-height: 24px; margin: var(--v2-sp-sec) 6px var(--v2-sp-head); }
/* A 44px (+) or link in a title row keeps its tap area but not its height, so every title sits the same
   distance from its card. */
.ui-v2 .v2-sec-head > :is(button, a) { margin-block: -10px; }
.ui-v2 .v2-sec-head__title { flex: 1; min-width: 0; margin: 0; font-size: var(--v2-fs-section); font-weight: 700; color: var(--c-text); }
.ui-v2 .v2-sec-head__total { font-size: 14px; font-weight: 700; color: var(--c-text); white-space: nowrap; }
.ui-v2 .v2-add {
    flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
    background: var(--c-primary-soft); color: var(--c-primary); font-size: 16px; cursor: pointer;
}

/* ── Pills, segmented switch, chips ── */
.ui-v2 .v2-pill { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: var(--radius-pill); background: var(--c-surface-2); color: var(--c-text); font-size: 12px; font-weight: 700; white-space: nowrap; }
.ui-v2 .v2-pill--ok { background: var(--c-success-soft); color: var(--c-success); }
.ui-v2 .v2-pill--warn { background: var(--c-warning-soft); color: #92400e; }
.ui-v2 .v2-pill--bad { background: var(--c-danger-soft); color: var(--c-danger); }
.ui-v2 .v2-pill--move { background: var(--money-move-soft); color: var(--money-move); }
.ui-v2 .v2-pill--new { background: var(--c-primary-soft); color: var(--c-primary); }   /* an AI guess / a suggestion (phase 7) */

.ui-v2 .v2-seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--c-surface-2); }
.ui-v2 .v2-seg > * {
    flex: 1; min-height: 44px; border: 0; border-radius: 11px; background: none; color: var(--c-text-muted);
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; display: grid; place-items: center;
}
.ui-v2 .v2-seg > .is-on { background: var(--c-surface); color: var(--c-text); box-shadow: var(--el-1); }
.ui-v2 .v2-seg > * { transition: color var(--mo-base) var(--ease-out); }

.ui-v2 .v2-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.ui-v2 .v2-chips::-webkit-scrollbar { display: none; }
.ui-v2 .v2-chip {
    flex: none; min-height: 44px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--c-border);
    background: var(--c-surface); color: var(--c-text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.ui-v2 .v2-chip.is-on { background: var(--c-primary-soft); border-color: var(--c-primary-line); color: var(--c-primary); }

/* ── Detail sheet (phases 5–8): a bottom sheet on phones, a centred window on desktop ── */
.ui-v2 .v2-sheet { background: var(--c-surface); border-radius: 26px 26px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); box-shadow: var(--el-3); }
.ui-v2 .v2-sheet__head { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.ui-v2 .v2-sheet__body { padding: 4px 0 12px; }
.ui-v2 .v2-sheet__actions { display: flex; gap: 8px; padding-top: 8px; }
.ui-v2 .v2-sheet__actions > * { flex: 1; }
@media (min-width: 769px) { .ui-v2 .v2-sheet { border-radius: 22px; } }

/* ── Form field and buttons ── */
.ui-v2 .v2-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.ui-v2 .v2-field > label { font-size: 13px; font-weight: 600; color: var(--c-text-muted); }
.ui-v2 .v2-field > input, .ui-v2 .v2-field > select, .ui-v2 .v2-field > textarea {
    min-height: 48px; padding: 0 14px; border: 1px solid var(--c-border-strong); border-radius: 14px;
    background: var(--c-surface); color: var(--c-text); font: inherit; font-size: 16px;
}
.ui-v2 .v2-btn {
    min-height: 50px; padding: 0 18px; border-radius: 16px; border: 1px solid var(--c-border);
    background: var(--c-surface); color: var(--c-text); font: inherit; font-size: 15px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
    transition: transform var(--mo-fast) var(--ease-out);
}
.ui-v2 .v2-btn:active { transform: scale(.98); }
.ui-v2 .v2-btn--primary { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on-primary); }
.ui-v2 .v2-btn--danger { color: var(--c-danger); }

/* ── Phone / desktop only ── */
@media (max-width: 768px) { .ui-v2 .v2-desktop-only { display: none !important; } }
@media (min-width: 769px) { .ui-v2 .v2-mobile-only { display: none !important; } }
