/* ════════════════════════════════════════════════════════════════
   SmartFin – Gold Fintech Theme
   Rich dark hero + floating white cards + gold + animations
   Mobile-First, RTL
   ════════════════════════════════════════════════════════════════ */

/* The font (Rubik) is loaded through <link> in the templates: faster than @import */

:root {
    /* Hero (dark) */
    --hero-bg:             #141007;
    --hero-bg-2:           #241A08;
    --hero-text:           #FFF8E7;
    --hero-text-muted:     rgba(255, 244, 214, 0.62);
    --hero-chip-bg:        rgba(255, 255, 255, 0.07);
    --hero-chip-border:    rgba(255, 255, 255, 0.13);

    /* Page (light) */
    --color-bg:            #F7F4ED;
    --color-bg-elevated:   #FFFDF8;
    --color-card:          #FFFFFF;
    --color-card-hover:    #FBF8F1;
    --color-input:         #F4F0E7;

    /* Gold */
    --color-gold:          #A67C00;
    /* The same gold, darker, for text only.
       #A67C00 on white gives 3.82:1, below the 4.5 the standard requires for
       text. It does pass the requirement for non-text content (3:1), so borders,
       lines and fills keep using it and the visual identity doesn't move.
       #846300 passes even in the hardest case: text on a translucent gold
       background over the page background (tags). */
    --color-gold-text:     #846300;
    --color-gold-bright:   #D4AF37;
    --color-gold-dim:      rgba(166, 124, 0, 0.10);
    --color-gold-border:   rgba(166, 124, 0, 0.28);
    /* Darkened so white text on it passes: the light end gave 2.75:1, far below
       the standard, and it is the primary button on sign-in, signup and the
       wizard. */
    --gradient-gold:       linear-gradient(150deg, #966F00 0%, #7F5F00 100%);
    --gradient-gold-text:  linear-gradient(150deg, #E3BE55 0%, #D4AF37 100%);

    /* Text */
    --color-text:          #1C1917;
    --color-text-soft:     #44403C;
    /* `#78716C` was `4.2:1` on the light background, below the 4.5 accessibility
       threshold (Matan, 13.10) */
    --color-text-muted:    #6B645F;

    /* Semantic */
    --color-income:        #15803D;
    --color-expense:       #B91C1C;
    /* Used only for savings amounts, which are text, so the same value as
       --color-gold-text and not as the brand gold. */
    --color-savings:       #846300;
    --color-income-light:  #4ADE80;
    --color-expense-light: #F87171;
    --color-savings-light: #E8C96A;
    --gradient-danger:     linear-gradient(135deg, #DC2626, #B91C1C);

    /* Ink for lines and subtle backgrounds (`rgba(var(--ink-rgb), 0.07)`): flips
       in dark mode */
    --ink-rgb:             28, 25, 23;
    /* alerts and warning cards */
    --alert-warn-bg:       #FDF6E7;
    --alert-warn-ink:      #6E5200;
    --alert-danger-bg:     #FCEDED;
    --alert-danger-ink:    #8E1A1A;
    /* The "off" track: #D8D2C4 was 1.5:1, and the switch's state didn't read (3.5) */
    --toggle-off:          #8F8777;
    /* Translucent + blur (`.bottom-nav`). At 0.97 without blur the content behind
       flashed sharply between the labels; this way it becomes a soft patch of
       colour. */
    --dock-bg:             rgba(255, 253, 248, 0.72);
    --dock-bg-solid:       #FFFDF8;

    /* Borders & shadows */
    --border-subtle:       1px solid rgba(var(--ink-rgb), 0.07);
    --border-gold:         1px solid var(--color-gold-border);
    --shadow-card:         0 1px 2px rgba(31, 24, 8, 0.04), 0 4px 14px rgba(31, 24, 8, 0.05);
    --shadow-lift:         0 8px 28px rgba(31, 24, 8, 0.09), 0 2px 6px rgba(31, 24, 8, 0.05);
    --shadow-gold:         0 6px 18px rgba(166, 124, 0, 0.28);
    --shadow-dock:         0 8px 26px rgba(31, 24, 8, 0.10), 0 1px 4px rgba(31, 24, 8, 0.05);
    /* Things that float over the page: a small one (bars, toasts) and a big one
       (dialogs, the sign-in card). Landing-page mock-ups keep their own. */
    --shadow-float:        0 8px 26px rgba(20, 16, 7, 0.32);
    --shadow-overlay:      0 22px 54px rgba(20, 16, 7, 0.36);
    --divider-subtle:      rgba(var(--ink-rgb), 0.06);

    /* Layout */
    --radius:              14px;
    --radius-sm:           11px;
    --dock-height:         62px;
    --dock-gap:            12px;

    /* Fonts */
    --font-body:           'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display:        'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* ─── Scales (design pass, stage 2, 11.11) ───
       Added with exact-value replacement only: nothing on screen moved. The
       values still written by hand are the list for consolidation. */
    /* Layers, bottom to top */
    --z-skeleton:          45;
    --z-dock:              50;
    --z-fab:               51;
    --z-sticky:            60;
    --z-screen:            95;
    --z-sheet:             100;
    --z-dialog:            150;
    --z-picker:            180;
    --z-banner:            190;
    --z-toast:             200;
    --z-viewer:            400;
    --z-install:           950;
    /* Corners (with --radius-sm 11px and --radius 14px above) */
    --radius-xs:           8px;
    --radius-lg:           20px;
    --radius-sheet:        26px;
    --radius-pill:         999px;
    /* Type, rem so the text-size setting scales it */
    --text-2xs:            0.75rem;    /* 12px: the smallest text in the app (audit, 22.11; was 11.5) */
    --text-xs:             0.75rem;
    --text-sm:             0.8125rem;
    --text-md:             0.875rem;
    --text-body:           0.92rem;
    --text-base:           1rem;
    --text-title:          1.1rem;
    --text-lg:             1.25rem;
    --text-xl:             1.5rem;
    --text-display:        1.65rem;
    /* Motion */
    --dur-fast:            120ms;
    --dur-quick:           0.15s;
    --dur-base:            0.2s;
    --dur-medium:          0.25s;
    --dur-slow:            0.3s;
    --ease-out:            cubic-bezier(0.22, 1, 0.36, 1);
    --ease-sheet:          cubic-bezier(0.32, 0.72, 0, 1);
    --ease-exit:           cubic-bezier(0.4, 0, 1, 1);
}

/* ═══ Dark mode: manual only, from settings → appearance (Matan, 30.9, round 6,
   item 4) ═══
   The same style: dark brown instead of white, the same gold. Green, red and
   gold lighter: the light theme's shades give too little contrast for text on a
   dark background.
   `data-theme` is set in js/theme.js, in <head>, before painting. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --hero-bg:             #0B0904;
    --hero-bg-2:           #1A1306;

    --color-bg:            #15110A;
    --color-bg-elevated:   #1B160E;
    --color-card:          #211B12;
    --color-card-hover:    #282115;
    --color-input:         #2B2418;

    --color-gold-text:     #E3BE55;
    --color-gold-dim:      rgba(212, 175, 55, 0.14);
    --color-gold-border:   rgba(212, 175, 55, 0.35);

    --color-text:          #F4EFE4;
    --color-text-soft:     #D9D1C2;
    --color-text-muted:    #A69D8C;

    --color-income:        #4ADE80;
    --color-expense:       #F87171;
    --color-savings:       #E8C96A;

    --ink-rgb:             255, 244, 214;
    --alert-warn-bg:       #2E2412;
    --alert-warn-ink:      #F0CF7A;
    --alert-danger-bg:     #361A18;
    --alert-danger-ink:    #FCA5A5;
    --toggle-off:          #746A57;
    --dock-bg:             rgba(33, 27, 18, 0.72);
    --dock-bg-solid:       #211B12;

    --border-subtle:       1px solid rgba(255, 244, 214, 0.08);
    --shadow-card:         0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.30);
    --shadow-lift:         0 8px 28px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.30);
    --shadow-dock:         0 8px 26px rgba(0, 0, 0, 0.50), 0 1px 4px rgba(0, 0, 0, 0.30);
    --divider-subtle:      rgba(255, 244, 214, 0.07);
}
/* "Whose" tags: the light theme's dark shades aren't readable on a dark card */
:root[data-theme="dark"] .owner-0 { background: rgba(96, 165, 250, 0.16);  color: #93C5FD; }
:root[data-theme="dark"] .owner-1 { background: rgba(167, 139, 250, 0.16); color: #C4B5FD; }
:root[data-theme="dark"] .owner-2 { background: rgba(236, 120, 190, 0.16); color: #F0A6D3; }
:root[data-theme="dark"] .owner-3 { background: rgba(234, 140, 100, 0.16); color: #F4B08F; }
:root[data-theme="dark"] .owner-4 { background: rgba(148, 170, 200, 0.16); color: #B8C8DD; }
:root[data-theme="dark"] .owner-5 { background: rgba(190, 160, 130, 0.16); color: #D7BFA6; }
:root[data-theme="dark"] .owner-6 { background: rgba(129, 140, 248, 0.16); color: #A5B4FC; }
:root[data-theme="dark"] .owner-7 { background: rgba(94, 180, 200, 0.16);  color: #8FD0E0; }

/* ─── Reset & base ─────────────────────────────────────────────── */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    /* A sideways swipe doesn't change page (Matan, 11.10: "when I scroll it moves
       me between pages"): on Android this turns off the browser's swipe-back. On
       iPhone the system gesture stays, so switching tabs doesn't go into history
       (`core.js`): there is nowhere to go back to. */
    overscroll-behavior-x: none;
    /* Without the grey square the phone paints on every touch: the most obvious
       sign that "this is a website". Buttons have their own `:active` (Matan,
       7.10, touch round, item 1) */
    -webkit-tap-highlight-color: transparent;
}

/* Buttons behave like buttons (touch round, 7.10):
   `manipulation`: a quick double tap (two categories, + twice) doesn't zoom the
   screen, and the tap registers immediately. Pinch zoom stays.
   `user-select`: a long press on "save" doesn't select the word. Only on
   controls: amounts, descriptions and codes stay copyable. */
button, a, [role="button"], label, summary, select {
    touch-action: manipulation;
}
button, [role="button"], summary, .nav-item, a.btn-sm, a.submit-btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
/* Text size, from settings → appearance, per phone (Matan, 30.9, round 6,
   item 9). Every size on the page is in rem, so one change here scales
   everything together. */
html[data-text-size="large"]  { font-size: 112.5%; }
html[data-text-size="xlarge"] { font-size: 125%; }
/* "Extra large" on a narrow screen: the percentage on a category row makes room
   for the name; without it "משכורת" was cut to one letter next to a six-digit
   amount. The percentage stays in the chart and at other sizes. */
@media (max-width: 380px) {
    html[data-text-size="xlarge"] .legend-pct { display: none; }
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    /* One pixel taller than the screen, even on a short page (Matan, 30.9). In
       the app installed on iPhone, a page with nothing to scroll gets a screen
       that ends above the home indicator, and the bottom menu (which already
       adds the home indicator's margin) "rose" twice that height. It happened
       only on the projects page, when every project had already finished. A page
       that scrolls, even by a pixel, gets the full screen, like every other page. */
    min-height: calc(100vh + 1px);
    min-height: calc(100lvh + 1px);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

ul { list-style: none; }

/* ─── Page hero (dark band) ───────────────────────────────────── */

.page-hero {
    background:
        radial-gradient(ellipse 110% 80% at 85% -20%, rgba(212, 175, 55, 0.11), transparent 55%),
        linear-gradient(160deg, var(--hero-bg-2) 0%, var(--hero-bg) 70%);
    color: var(--hero-text);
    /* 28px under the clock, not 14: iOS 26 blurs a band a little taller than
       the safe area, and the greeting sat inside it (Matan's iPhone, 11.11) */
    padding: calc(28px + env(safe-area-inset-top, 0px)) 20px 46px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.18);
    position: relative;
}
/* In dark mode the background under the strip is as dark as it, and only the
   line remains, crossing the first card in the middle and looking like a
   scratch (Matan, 12.10). In light mode it is the border between dark and cream. */
:root[data-theme="dark"] .page-hero { border-bottom-color: transparent; }

.hero-inner {
    max-width: 560px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Main content floats over the hero */
.main-content {
    position: relative;
    z-index: 2;
    max-width: 560px;
    margin: -30px auto 0;
    /* Room for the bar only: the + sits on its own row and not over the content
   (Matan, 11.10) */
    padding: 0 16px calc(var(--dock-height) + var(--dock-gap) + env(safe-area-inset-bottom, 0px) + 24px);
}

/* ─── Hero typography & header ────────────────────────────────── */

.hero-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

/* The magnifying glass on the home page (Matan, 30.9) */
.hero-actions { display: flex; align-items: center; gap: 10px; }
/* Level with the middle of the greeting and the title, not the greeting's top
   edge, so it sits clear of the blur under the clock too (Matan, 11.11) */
.hero-top > .hero-actions { align-self: center; }
.hero-icon-btn {
    width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #F4EFE4;
}
.hero-icon-btn svg { width: 20px; height: 20px; }

.greeting {
    color: var(--hero-text-muted);
    font-size: var(--text-md);
    font-weight: 400;
}

.month-title,
.hero-title {
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--hero-text);
}

.hero-badge {
    display: inline-block;
    vertical-align: middle;
    font-size: var(--text-2xs);
    font-weight: 600;
    color: var(--hero-text-muted);
    background: var(--hero-chip-bg);
    border: 1px solid var(--hero-chip-border);
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    margin-inline-start: 6px;
}

.hero-subtitle {
    color: var(--hero-text-muted);
    font-size: var(--text-md);
    margin-top: 2px;
}

/* A secondary explanation line at the top of a page, e.g. "not included in the
   month's balance" on projects (Matan, 3.10) */
.hero-note { color: var(--hero-text-muted); font-size: var(--text-xs); margin-top: 6px; line-height: 1.45; opacity: 0.85; }

/* Settings: the family name on the left, on the same row as the title (Matan,
   1.10). A long name wraps to two lines on its own side and doesn't push
   "settings". */
.settings-hero-top { align-items: center; gap: 16px; }
.settings-family-name {
    min-width: 0;
    text-align: left;
    font-size: var(--text-title);
    font-weight: 700;
    line-height: 1.25;
    color: var(--hero-text);
    overflow-wrap: anywhere;
}

.back-to-current {
    color: var(--color-gold-bright);
    font-weight: 600;
    text-decoration: none;
    position: relative;
}

/* Big hero amount */
.hero-balance {
    text-align: center;
    padding: 10px 0 0;
}

.hero-label {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--hero-text-muted);
    /* Wide letter spacing belongs to English capitals; in Hebrew it breaks words
   apart (Matan, 7.10) */
    letter-spacing: 0.01em;
    margin-bottom: 2px;
}

.hero-amount {
    font-size: 2.7rem;
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;   /* A large number: tighten, otherwise the digits look scattered */
    color: var(--hero-text);    /* "יצא החודש", with no income yet: neither good nor bad */
    direction: ltr;
}

/* Green above zero and red below (Matan, 29.11), as in the comparison table.
   It was the brand's gold: gold is also the colour of savings, so a good month
   read as an amount saved. */
.hero-amount.surplus { color: var(--color-income-light); }
.hero-amount.deficit { color: var(--color-expense-light); }

.hero-sub {
    margin-top: 4px;
    font-size: var(--text-md);
    color: var(--hero-text-muted);
}

.hero-empty-message {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--hero-text);
    margin-top: 2px;
}

.hero-bar {
    margin-top: 18px;
}
/* The home hero, shorter (Matan, 22.11): see index.html */
.hero-top-home { margin-bottom: 4px; align-items: center; }
.hero-balance { padding-top: 0; }
.hero-balance .hero-amount { font-size: 2.25rem; }
.hero-balance .hero-sub { margin-top: 0; }
.hero-balance .hero-bar { margin-top: 10px; }

/* Progress bar on dark hero */
.page-hero .balance-bar-track {
    background: rgba(255, 255, 255, 0.12);
}

.page-hero .balance-bar-legend {
    color: var(--hero-text-muted);
}

/* Month nav arrows on hero */
.stats-month-nav {
    display: flex;
    gap: 8px;
}

.stats-nav-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--hero-chip-bg);
    border: 1px solid var(--hero-chip-border);
    color: var(--color-gold-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-lg);
    text-decoration: none;
    line-height: 1;
    transition: background 0.2s;
}

.stats-nav-btn:active {
    background: rgba(255, 255, 255, 0.16);
}

.stats-nav-btn svg { width: 17px; height: 17px; }

/* KPI chips inside hero */
/* ════ Magnetic month strip (top of the month page) ════
   The browser does the "magnet" by itself through scroll-snap, with no JS and no
   scroll listener, so the drag stays on a separate thread and doesn't stall
   while the page is busy. */

.month-strip {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding: 2px 0 4px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* the drag doesn't bleed into the page behind at the edges */
    overscroll-behavior-x: contain;
    /* A clean scrollbar: Firefox + old IE/Edge (webkit is handled separately below) */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.month-strip::-webkit-scrollbar { display: none; }

/* Virtual padding at the edges: without it the first and last items can't centre */
.month-strip::before,
.month-strip::after {
    content: '';
    flex: 0 0 calc(50% - 56px);
}

.month-chip {
    scroll-snap-align: center;
    /* doesn't skip months on a fast drag */
    scroll-snap-stop: always;
    flex: 0 0 104px;
    background: var(--hero-chip-bg);
    border: 1px solid var(--hero-chip-border);
    border-radius: var(--radius-sm);
    padding: 9px 8px;
    text-align: center;
    text-decoration: none;
    color: var(--hero-text);
    opacity: 0.5;
    transform: scale(0.94);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.25s ease,
                border-color 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.month-chip.is-current {
    opacity: 1;
    transform: scale(1);
    background: var(--color-gold-dim);
    border-color: var(--color-gold-border);
}

.month-chip-name {
    font-size: var(--text-md);
    font-weight: 600;
    white-space: nowrap;
}

.month-chip.is-current .month-chip-name { color: var(--color-gold-bright); }

.month-chip-year {
    font-size: var(--text-xs);
    color: var(--hero-text-muted);
    margin-top: 1px;
}

/* "סיכום החודש" under the three numbers of a month that ended (Matan, 1.12).
   On the page's dark top in both themes, so its gold is the bright one. */
.month-recap-btn {
    margin-top: 12px; width: 100%; min-height: 46px; display: flex; justify-content: center; align-items: center; gap: 8px;
    border-radius: var(--radius-sm); background: rgba(212, 175, 55, 0.16); border: 1px solid rgba(212, 175, 55, 0.45);
    color: #E3BE55; font: inherit; font-size: var(--text-md); font-weight: 700; cursor: pointer;
}
.month-recap-btn[hidden] { display: none; }
.month-recap-icon { display: inline-flex; }
.month-recap-icon svg { width: 18px; height: 18px; }
/* The arrow that points on, as on the home page's card */
.month-recap-btn::after {
    content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 0 2px 2px; transform: rotate(45deg);
}
.month-recap-btn:active { opacity: 0.75; }
.month-recap-btn:focus-visible { outline: 2px solid #E3BE55; outline-offset: 2px; }
.kpi-chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.kpi-chip {
    container-type: inline-size;   /* for the amount's `cqi`, see `.summary-card` */
    background: var(--hero-chip-bg);
    border: 1px solid var(--hero-chip-border);
    border-radius: var(--radius-sm);
    padding: 9px 8px;
    text-align: center;
}

.kpi-chip .kpi-label {
    font-size: var(--text-xs);
    color: var(--hero-text-muted);
    margin-bottom: 2px;
}

.kpi-chip .kpi-value {
    font-weight: 600;
    font-size: min(0.98rem, 16cqi);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    white-space: nowrap;
    color: var(--hero-text);
}

.kpi-chip .kpi-value.income  { color: var(--color-income-light); }
.kpi-chip .kpi-value.expense { color: var(--color-expense-light); }
.kpi-chip .kpi-value.savings { color: var(--color-savings-light); }
.kpi-chip .kpi-value.surplus { color: var(--color-income-light); }
.kpi-chip .kpi-value.deficit { color: var(--color-expense-light); }

/* Hero totals row (compare page) */
.hero-totals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

/* The month page: the monthly balance in a wide box, and under it three equal
   boxes (Matan, 30.9) */
.month-net {
    margin-top: 14px;
    background: var(--hero-chip-bg);
    border: 1px solid var(--hero-chip-border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.month-net .kpi-label {
    font-size: var(--text-xs);
    color: var(--hero-text-muted);
    margin-bottom: 2px;
}

.month-net-value {
    font-weight: 700;
    font-size: var(--text-display);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    color: var(--hero-text);
}

/* The same colours as the balance on the home page: one balance, one look */
.month-net.surplus .month-net-value { color: var(--color-income-light); }
.month-net.deficit .month-net-value { color: var(--color-expense-light); }

.kpi-chips.kpi-chips-three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 8px; }

/* The project balance: a wide row under the tiles */
.project-net {
    margin-top: 14px;
    background: var(--hero-chip-bg);
    border: 1px solid var(--hero-chip-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    text-align: center;
}

.project-net .kpi-label {
    font-size: var(--text-xs);
    color: var(--hero-text-muted);
    margin-bottom: 2px;
}

.project-net-value {
    font-weight: 700;
    font-size: var(--text-xl);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    color: var(--hero-text);
}

.project-net.surplus .project-net-value { color: var(--color-income-light); }
.project-net.deficit .project-net-value { color: var(--color-expense-light); }

/* Settings hero profile */
.hero-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
}

.hero-profile .member-avatar-lg {
    width: 46px;
    height: 46px;
    font-size: var(--text-base);
}

.hero-profile-name {
    font-weight: 700;
    font-size: var(--text-title);
    color: var(--hero-text);
}

.hero-profile-sub {
    font-size: var(--text-sm);
    color: var(--hero-text-muted);
}

/* ─── Floating navigation dock ────────────────────────────────── */

/* The bar and the + are one centred group (Matan, 11.10): the + sits to the
   left of the bar, on the same row, and doesn't float over the content, where it
   looked as if it belonged to what was above it ("for the whole month").
   `--dock-w`: the group's width; `--dock-side`: the margin on each side. */
:root {
    --fab-size: 52px;
    --dock-w: min(calc(100vw - 2 * var(--dock-gap)), 560px);
    --dock-side: calc((100vw - var(--dock-w)) / 2);
}
.bottom-nav {
    position: fixed;
    bottom: calc(var(--dock-gap) + env(safe-area-inset-bottom, 0px));
    left: calc(var(--dock-side) + var(--fab-size) + 14px);
    right: var(--dock-side);
    z-index: var(--z-dock);
    height: var(--dock-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--dock-bg);
    /* A translucent material, Apple-style (Matan, 7.10, item 5): the content
       scrolls under it blurred, and the bar looks like it floats over the page
       rather than a strip taking up space */
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(var(--ink-rgb), 0.08);
    /* A capsule: round ends like the + next to it (Matan, 11.10) */
    border-radius: calc(var(--dock-height) / 2);
    box-shadow: var(--shadow-dock);
    padding: 0 12px;
}

/* Whoever asked their phone for reduced transparency, or high contrast: an
   opaque bar as before */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
    .bottom-nav {
        background: var(--dock-bg-solid);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
    padding: 6px 0;
    text-decoration: none;
    color: var(--color-text-muted);
    transition: color var(--dur-medium);
    -webkit-tap-highlight-color: transparent;
}

.nav-item .nav-icon {
    width: 40px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);          /* like the bar and the + (Matan, 11.10) */
    transition: background 0.3s cubic-bezier(0.22, 1, 0.36, 1), color 0.25s, transform 120ms ease-out;
}

/* Press feedback: the button responds the moment it is touched, not only when
   the page changes (Matan, 7.10, motion round, item 6). Subtle on purpose: these
   are tapped dozens of times a day. In the bar only the icon shrinks: the whole
   button is a quarter of the width, and it looked like a jump. */
.nav-item:active .nav-icon { transform: scale(0.94); }

.nav-item .nav-icon svg {
    width: 20px;
    height: 20px;
}

.nav-item .nav-label {
    font-size: var(--text-xs);
    font-weight: 500;
    transition: color var(--dur-medium);
}
.nav-item { min-width: 0; }

/* The dock on a narrow screen with large text (design pass, 11.11): at 320px and
   "extra large" the five labels touched each other and "הגדרות" ran under the +.
   The labels go back to about their normal size there; the icons carry them. */
@media (max-width: 380px) {
    /* Each item as wide as its own label, not a fifth of the bar: "פרויקטים" is
       twice "בית". The icon pill narrows a little to make room. */
    .bottom-nav { padding: 0 4px; }
    .nav-item { flex: 1 1 auto; }
    .nav-item .nav-icon { width: 34px; }
    /* Not on the type scale on purpose: these are fitted to the width of the bar */
    .nav-item .nav-label { font-size: 0.7rem; }
    html[data-text-size="large"] .nav-item .nav-label  { font-size: 0.62rem; }
    html[data-text-size="xlarge"] .nav-item .nav-label { font-size: 0.56rem; }
}
/* "Extra large" on an ordinary phone too (audit, 1.12): at 390px "פרויקטים" was
   wider than its fifth of the bar and the labels read as one line. The same
   two steps as above: each item as wide as its label, and the label a size down. */
@media (min-width: 381px) and (max-width: 480px) {
    html[data-text-size="xlarge"] .nav-item { flex: 1 1 auto; }
    html[data-text-size="xlarge"] .nav-item .nav-label { font-size: 0.62rem; }
}

.nav-item.active {
    color: var(--color-gold-text);
}

.nav-item.active .nav-icon {
    background: var(--color-gold-dim);
    color: var(--color-gold-text);
}

.nav-item.active .nav-label {
    font-weight: 600;
}

/* ─── Cards & sections ────────────────────────────────────────── */

.summary-cards {
    display: grid;
    /* `minmax(0, …)`: a `1fr` column doesn't shrink below its content, and an
       amount with agorot ("₪28,765.43") pushed the page sideways at width 390
       and cut off the savings at 375 */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
    /* One card with dividing lines, not three floating cards (Matan, 11.10) */
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.summary-card {
    container-type: inline-size;
    padding: 10px 8px;
    text-align: center;
    transition: background-color 0.16s ease;
}

.summary-card + .summary-card { border-inline-start: 1px solid rgba(var(--ink-rgb), 0.07); }

/* ── The cards and tiles are tappable: they lead to the type's breakdown on
   the month page ── */
a.summary-card,
a.kpi-chip {
    display: block;
    position: relative;
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

a.kpi-chip:active { transform: scale(0.97); }

/* The breakdown arrived at: room under the top of the screen, and a short gold
   flash */
#income-breakdown,
#expense-breakdown,
#savings-breakdown {
    /* In the app installed on iPhone the page is also painted under the clock and
       the dynamic island, so 14px from the top of the screen is inside that band:
       Matan: "the island is really stepping on it". And above the card the
       sticky header appears too (`.month-sticky`, 44px under the band); without
       it the top of the card was cut off (Matan, 2.10). Since 22.11 the bar
       carries a row of shortcuts too: 88 + 16 = 104. */
    scroll-margin-top: calc(104px + env(safe-area-inset-top, 0px));
}
/* The other sections the shortcuts jump to */
#allTx, #month-projects { scroll-margin-top: calc(104px + env(safe-area-inset-top, 0px)); }

.chart-card.flash {
    /* The flash replaces the entrance animation (`.anim-rise`, `motion.js`),
       which starts at `opacity: 0` and stays at 1 only while it is active.
       Without this line the card jumped to disappeared entirely: Matan: "you
       can't see anything, as if it was erased" */
    opacity: 1;
    transform: none;
    animation: breakdown-flash 1.6s ease-out;
}

.category-grid.flash {
    border-radius: var(--radius-sm);
    animation: breakdown-flash 1.6s ease-out;
}

/* An empty row (`.empty-row`) reached from the tile above: the same flash */
.empty-row.flash {
    animation: breakdown-flash 1.6s ease-out;
}

/* The category an alert led to (Matan, 11.10): the same spacing from the
   sticky header as the breakdowns */
.legend-item-wrap[id] { scroll-margin-top: calc(104px + env(safe-area-inset-top, 0px)); }

.legend-item-wrap.flash {
    border-radius: var(--radius-sm);
    animation: breakdown-flash 1.6s ease-out;
}

@keyframes breakdown-flash {
    0%, 30% { box-shadow: 0 0 0 3px var(--color-gold), var(--shadow-card); }
    100%    { box-shadow: 0 0 0 0 transparent, var(--shadow-card); }
}

@media (prefers-reduced-motion: reduce) {
    .chart-card.flash,
    .category-grid.flash,
    .empty-row.flash,
    .legend-item-wrap.flash { animation: none; outline: 3px solid var(--color-gold); outline-offset: 2px; }
}

/* A cell inside a card: a tap highlights it, doesn't move it */
.summary-card:active {
    background: var(--color-card-hover);
}

.summary-card .card-icon {
    width: 24px;
    height: 24px;
    margin: 0 auto 4px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-card .card-icon svg {
    width: 13px;
    height: 13px;
}

.summary-card.income .card-icon {
    background: rgba(21, 128, 61, 0.07);
    color: var(--color-income);
}

.summary-card.expense .card-icon {
    background: rgba(185, 28, 28, 0.06);
    color: var(--color-expense);
}

.summary-card.savings .card-icon {
    background: rgba(166, 124, 0, 0.07);
    color: var(--color-gold-text);
}

.summary-card .card-label {
    font-size: var(--text-xs);
    line-height: 1.3;
    color: var(--color-text-muted);
    margin-bottom: 1px;
}

.summary-card .card-amount {
    /* Exactly as small as needed to fit: `cqi` is a percentage of the card width.
       In a wide card, the original size */
    font-size: min(1.02rem, 16cqi);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    white-space: nowrap;
}

.summary-card.income  .card-amount { color: var(--color-income); }
.summary-card.expense .card-amount { color: var(--color-expense); }
.summary-card.savings .card-amount { color: var(--color-savings); }

/* Balance bar (shared) */
.balance-bar-track {
    height: 8px;
    border-radius: var(--radius-pill);
    background: rgba(var(--ink-rgb), 0.08);
    overflow: hidden;
}

.balance-bar-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--gradient-gold);
    transition: width 0.9s var(--ease-out);
}

.balance-bar-fill.danger {
    background: var(--gradient-danger);
}

.balance-bar-legend {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* ─── Transactions list ───────────────────────────────────────── */

.transactions-section {
    margin-bottom: 18px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
    margin-bottom: 10px;
}

.section-header h2 {
    font-size: var(--text-base);
    font-weight: 700;
}

.see-all-link {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-gold-text);
    text-decoration: none;
    /* A 20px height was too small for a finger; the padding enlarges the tap
       area to 44 and the negative margin keeps the text in place */
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 10px;
    margin: -12px -10px;
}

.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}


/* The row is a container, and the padding is on .tx-head: the swipe panels
   sit on it */
.transaction-item {
    display: block;
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    transition: transform 0.15s, background 0.2s, opacity 0.25s ease, box-shadow 0.25s ease,
                border-color 0.25s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tx-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

.transaction-item:active {
    background: var(--color-card-hover);
    transform: scale(0.99);
}

.tx-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--color-input);
}

.tx-icon.income  { background: rgba(21, 128, 61, 0.07); }
.tx-icon.expense { background: rgba(185, 28, 28, 0.06); }
.tx-icon.savings { background: rgba(166, 124, 0, 0.07); }

.tx-emoji { font-size: var(--text-title); }

.tx-details {
    flex: 1;
    min-width: 0;
}

.tx-name {
    font-weight: 600;
    font-size: var(--text-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-meta {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.tx-amount {
    font-weight: 700;
    font-size: var(--text-body);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    white-space: nowrap;
}

.tx-amount.income  { color: var(--color-income); }
.tx-amount.expense { color: var(--color-expense); }
.tx-amount.savings { color: var(--color-savings); }

/* ── Coloured name tags: who the transaction belongs to ── */

.owner-pill {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.owner-pill-sm {
    font-size: var(--text-xs);
    padding: 2px 7px;
    flex-shrink: 0;
}

/* Family member colours: unusual, and not clashing with the semantic colours
   (green=income, red=expense, gold=savings). Must stay in sync with _OWNER_HEX
   in app.py (used in the "by family member" chart). */
.owner-0 { background: rgba(46, 103, 168, 0.12); color: #2E67A8; }  /* blue (Matan) */
.owner-1 { background: rgba(112, 72, 176, 0.12); color: #7048B0; }  /* purple (Or) */
.owner-2 { background: rgba(160, 69, 124, 0.12); color: #A0457C; }  /* plum-magenta */
/* 3–5 darkened (design pass, 11.11): 4.2:1 at this size, below the 4.5 for text */
.owner-3 { background: rgba(143, 77, 51, 0.12);  color: #8F4D33; }  /* terracotta */
.owner-4 { background: rgba(78, 97, 128, 0.12); color: #4E6180; }  /* slate blue-grey */
.owner-5 { background: rgba(115, 88, 67, 0.12); color: #735843; }  /* taupe brown */
.owner-6 { background: rgba(75, 79, 168, 0.12);  color: #4B4FA8; }  /* indigo */
.owner-7 { background: rgba(47, 115, 133, 0.12); color: #2F7385; }  /* petrol blue */
.owner-shared { background: rgba(var(--ink-rgb), 0.07); color: var(--color-text-muted); }

/* The sheet gets focus on open on a phone (instead of the amount): no outline
   around it */
.modal-sheet:focus { outline: none; }

/* Line icons in buttons and markers (`backend/icons.py`, Matan 12.10): at the
   text's size and in its colour, like the character they replace */
.ui-icon { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.14em; }
.scan-btn-icon { display: inline-flex; }

/* An attached-receipt tag: a tap opens the image, not the transaction edit */
.receipt-badge {
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--color-gold-dim);
    font-size: var(--text-sm);
    line-height: 1;
    cursor: pointer;
    /* The icon changed from <button> to <a> (opening a receipt on iOS), so it
       needs what a button got for free */
    text-decoration: none;
    color: var(--color-gold-text);
}

/* A real touch area: the icon itself is 22px, below the accessibility minimum,
   and it sits inside a row that is both dragged and tapped: a miss opens the
   edit modal instead of the receipt. The same pattern as .install-bar-close and
   .cat-move-btn. */
.receipt-badge::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
}

@media (hover: hover) and (pointer: fine) { .receipt-badge:hover { background: var(--color-gold-border); } }

/* On transaction rows the pin is at text height, so it doesn't make the row
   taller (Matan, 30.9). The tap area stays 44px through `::before`, which takes
   no space in the layout. */
.cat-tx-row .receipt-badge,
.tx-amount-row .receipt-badge {
    width: 18px;
    height: 18px;
    font-size: var(--text-2xs);
    margin-block: -4px;     /* contributes nothing to the row's height, not even a pixel */
}

.tx-amount-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

/* ─── Empty state ─────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 44px 20px;
    background: var(--color-card);
    border: 1px dashed var(--color-gold-border);
    border-radius: var(--radius);
}

/* An empty-state illustration (`icons.empty_illus`, Matan 12.10): a gold line
   icon in a soft circle, in the same style as the bar and buttons, instead of a
   large emoji */
.empty-illus {
    width: 64px; height: 64px; margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--color-gold-dim); color: var(--color-gold-text);
}
.empty-illus .ui-icon { width: 30px; height: 30px; stroke-width: 1.7; vertical-align: 0; }

.empty-text {
    font-weight: 600;
    color: var(--color-text-soft);
}

.empty-sub {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* ─── "Add to home screen" (Matan, 13.10) ──────────────────────────
   A fixed dark bar above the bottom menu, until the first visit from the icon.
   See `js/pwa.js`. */
.install-bar {
    position: fixed; left: 16px; right: 16px; z-index: 950;
    bottom: calc(var(--dock-height) + var(--dock-gap) + env(safe-area-inset-bottom, 0px) + 10px);
    max-width: 528px; margin: 0 auto;
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border-radius: var(--radius-lg); border: 1px solid rgba(212, 175, 55, 0.35);
    background: linear-gradient(160deg, var(--hero-bg-2), var(--hero-bg)); color: #FFF8E7;
    box-shadow: var(--shadow-float);
}
.install-bar[hidden] { display: none; }
.install-bar-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); flex-shrink: 0; }
.install-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.install-bar-title { font-weight: 700; font-size: var(--text-body); }
.install-bar-sub { font-size: var(--text-xs); opacity: 0.7; margin-top: 1px; }
.install-bar-go {
    border: 0; border-radius: var(--radius-pill); padding: 9px 16px; min-height: 40px; flex-shrink: 0;
    font: inherit; font-weight: 700; font-size: var(--text-md); background: var(--gradient-gold); color: #FFFFFF; cursor: pointer;
}
.install-bar-close {
    position: relative; width: 26px; height: 26px; flex-shrink: 0; border: 0; background: none;
    color: inherit; opacity: 0.6; font-size: var(--text-sm); cursor: pointer;
}
.install-bar-close::before { content: ''; position: absolute; inset: -9px; }   /* 44px touch area */
/* the content isn't hidden under the bar */
body.has-install-bar .main-content {
    padding-bottom: calc(var(--dock-height) + var(--dock-gap) + env(safe-area-inset-bottom, 0px) + 96px);
}
/* Any open sheet, dialog or full screen hides the bar (design pass, 11.11): at
   z-index 950 it floated over the transaction sheet and covered the row above
   Save, and over "what's new". It comes back when the overlay closes. */
body:has(.modal-overlay.open, .confirm-overlay.open, .color-sheet:not([hidden]), .icon-picker:not([hidden]), .search-screen:not([hidden]), .tx-screen:not([hidden]), .receipt-viewer:not([hidden]), .yr-overlay:not([hidden])) .install-bar { display: none; }
/* The toast sat at the bar's height and was hidden behind it entirely, "added ·
   undo" included: above the bar instead (its 10px offset + ~62px + a gap) */
body.has-install-bar .toast {
    bottom: calc(var(--dock-height) + var(--dock-gap) + env(safe-area-inset-bottom, 0px) + 82px);
}
.install-steps { list-style: none; margin: 4px 0 14px; padding: 0; text-align: right; }
.install-steps li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--divider-subtle); }
.install-steps li:first-child { border-top: 0; }
.install-step-num {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    background: var(--color-gold-dim); color: var(--color-gold-text); font-weight: 700; font-size: var(--text-body);
}
.install-step-text { flex: 1; font-size: var(--text-body); line-height: 1.4; }
.install-step-hint { display: block; color: var(--color-text-muted); font-size: var(--text-sm); margin-top: 2px; }
.install-step-pic {
    width: 48px; height: 48px; border-radius: var(--radius-sm); flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    background: var(--color-input); color: #007AFF;
}
.install-step-pic svg { width: 26px; height: 26px; }
.install-step-pic img { width: 34px; height: 34px; border-radius: var(--radius-xs); }

/* ─── Alerts (overages) ──────────────────────────────────────────── */

.alerts-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.alert-card {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    font-weight: 500;
    line-height: 1.45;
    box-shadow: var(--shadow-card);
    border-inline-start: 3px solid;
}

.alert-card.warning {
    background: var(--alert-warn-bg);
    border-inline-start-color: var(--color-gold);
    color: var(--alert-warn-ink);
}

.alert-card.danger {
    background: var(--alert-danger-bg);
    border-inline-start-color: var(--color-expense);
    color: var(--alert-danger-ink);
}

/* ─── An empty row on the month page (Matan, 11.10) ─────────────────
   A type with no transactions this month: one row instead of an empty card, and
   "+ add" that opens the add sheet on that type */
.empty-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 12px 10px 16px;
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    font-size: var(--text-body);
    color: var(--color-text-muted);
    scroll-margin-top: calc(104px + env(safe-area-inset-top, 0px));
}
.empty-row-icon { font-size: var(--text-title); }
.empty-row-text { flex: 1; }
.empty-row-add {
    min-height: 36px;
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--color-gold-dim);
    color: var(--color-gold-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease;
}
.empty-row-add:active { transform: scale(0.96); }

/* An alert is a link to its target (Matan, 11.10) */
a.alert-card {
    display: block;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease;
}
a.alert-card:active { transform: scale(0.98); }

/* ─── FAB ─────────────────────────────────────────────────────── */

/* A gold circle to the left of the bar, at its mid-height (Matan, 11.10).
   Until then a gold square floating over the content: "too crude", and it
   looked like it belonged to what was above it. */
.fab {
    position: fixed;
    bottom: calc(var(--dock-gap) + env(safe-area-inset-bottom, 0px) + (var(--dock-height) - var(--fab-size)) / 2);
    left: calc(var(--dock-side) + 5px);
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    background: var(--gradient-gold);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(166, 124, 0, 0.30);
    z-index: var(--z-fab);
    transition: transform 0.2s;
}

.fab svg {
    width: 23px;
    height: 23px;
}

.fab:active {
    transform: scale(0.92);
}

/* ─── Entrance animations ─────────────────────────────────────── */

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.anim-rise {
    opacity: 0;
    animation: rise-in 0.55s var(--ease-out) forwards;
}

/* ─── Entering with the scroll (Matan, 11.10) ──────────────────────
   A card below the screen enters as you scroll to it, tied to the scroll: it
   rises and brightens exactly at the finger's pace, over its first 140 pixels on
   screen: the same distance for a short row and a tall card. `translate` and not
   `transform`, so as not to override the swipes, which write `transform` (the
   "this week" card). The first part of the entrance happens behind the
   translucent bar; at the end of the page even the last row is already whole
   (the bottom of `main` is taller than 140 minus a row height). */
@keyframes reveal-in {
    from { opacity: 0; translate: 0 28px; }
    to   { opacity: 1; translate: 0 0; }
}
@supports (animation-timeline: view()) {
    .reveal-scroll {
        animation: reveal-in linear both;
        animation-timeline: view(block);
        animation-range: entry 0% entry 140px;
    }
}
/* A browser without scroll-driven animations: a soft entrance the moment the
   card appears */
.reveal-fallback {
    opacity: 0;
    translate: 0 26px;
    transition: opacity 0.5s ease-out, translate 0.6s var(--ease-out);
}
.reveal-fallback.is-in { opacity: 1; translate: 0 0; }
@media (prefers-reduced-motion: reduce) {
    .reveal-scroll { animation: none; }
    .reveal-fallback { opacity: 1; translate: none; transition: none; }
}

/* ─── Toast + confirm dialog ─────────────────────────────────────── */

/* A locked "recurring transaction" checkbox: an occurrence already belonging to
   a series */
.recurring-group.is-locked .checkbox-label {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ─── The "no connection" bar ───────────────────────────────────── */
/* Below the toast (200) and above everything else: a message about a lasting
   state shouldn't cover a message about what just happened. */
.net-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-banner);
    /* Dark brown from the palette, not red: no connection is a fact about the
       environment, not an error the user made. #FFF3E2 on it gives 8.17:1. */
    background: #6B3F16;
    color: #FFF3E2;
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
    box-shadow: 0 2px 12px rgba(20, 16, 7, 0.28);
}

/* Explicit, and not relying on the browser's stylesheet: a bar that stays on
   screen after the connection returned is worse than a bar that never appeared. */
.net-banner[hidden] { display: none; }

.toast {
    position: fixed;
    bottom: calc(var(--dock-height) + var(--dock-gap) + env(safe-area-inset-bottom, 0px) + 14px);
    left: 50%;
    transform: translate(-50%, 12px);
    max-width: 320px;
    background: #24201A;
    color: #FFF8E7;
    font-size: var(--text-md);
    font-weight: 500;
    padding: 11px 20px;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-float);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: var(--z-toast);
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Up to two lines. `nowrap` + `ellipsis` cut every message longer than about 30
   characters in the middle, including the warning that the receipt was deleted,
   exactly the message that mustn't be lost. */
.toast .toast-msg {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    text-align: center;
}

.toast-action {
    flex-shrink: 0;
    pointer-events: auto;
    background: none;
    border: none;
    color: var(--color-gold-bright);
    font-family: inherit;
    font-size: var(--text-md);
    font-weight: 700;
    padding: 4px 2px;
    cursor: pointer;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* When the transaction sheet is open, a toast at the bottom landed on the date
   field. At the top it hides no field. */
body:has(.modal-overlay.open) .toast {
    bottom: auto;
    top: calc(14px + env(safe-area-inset-top, 0px));
}

.toast.error {
    background: #7A1D1D;
    color: #FDECEC;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-dialog);
    background: rgba(20, 16, 7, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-base), visibility var(--dur-base);
}

.confirm-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.2s, visibility 0s;   /* visible immediately on open; see `.modal-overlay.open` */
}

.confirm-card {
    width: 100%;
    max-width: 330px;
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: 22px 20px 18px;
    box-shadow: var(--shadow-overlay);
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.confirm-overlay.open .confirm-card {
    transform: scale(1);
}

.confirm-title {
    font-weight: 700;
    font-size: var(--text-base);
    margin-bottom: 6px;
}

.confirm-message {
    font-size: var(--text-md);
    color: var(--color-text-muted);
    margin-bottom: 18px;
    line-height: 1.5;
    white-space: pre-line;      /* A second line in the message: "הוזנה ע״י אור" */
}

.cat-grid-empty {
    grid-column: 1 / -1;
    font-size: var(--text-md);
    color: var(--color-text-muted);
    margin: 4px 0;
}

.confirm-choice {
    margin: -6px 0 18px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
}

.confirm-actions .btn-sm {
    flex: 1;
    padding: 11px 0;
}
/* Three answers: one under the other, the safe one first */
.confirm-actions.is-stacked { flex-direction: column; }
.confirm-actions .confirm-extra[hidden] { display: none; }

.confirm-yes {
    /* `--gradient-danger` and not `--color-expense`: in dark mode the text red is
       light, and white on it isn't readable */
    background: var(--gradient-danger);
    color: #FFFFFF;
}

/* Confirming an ordinary (non-destructive) action, e.g. syncing a recurring
   template */
.confirm-yes.confirm-yes-neutral {
    background: var(--gradient-gold);
    color: var(--hero-text);
}

/* ─── Modal (bottom sheet) ────────────────────────────────────── */

/* `visibility` and not just `opacity`: zero opacity hides from the eye only.
   The element stays focusable/clickable and stays in the accessibility tree,
   and that was true for every page in the app: the modal sits in base.html. In
   practice: pressing Tab past the bottom menu moved focus into an invisible form
   for about 15 presses, and VoiceOver read out the whole transaction form ("add
   transaction, expense, income, savings, amount in shekels…") on every screen,
   before the real content.
   `visibility` removes it from both, and still blends with the transition: it
   switches at once at the end of the transition, so the element stays visible
   throughout the gradual fade. */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-sheet);
    background: rgba(20, 16, 7, 0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-medium), visibility var(--dur-medium);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    /* On open, `visibility` switches **immediately** (on close, at the end of the
       fade, as before). With an ordinary transition it is still `hidden` at the
       first moment, exactly when the code moves focus to the amount field, and
       the browser refuses to focus inside a hidden element. Focus stayed on +,
       and Escape (caught inside the sheet) didn't close it (Matan, 7.10). */
    transition: opacity var(--dur-medium), visibility 0s;
}

.modal-sheet {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--color-bg-elevated);
    border-radius: 26px 26px 0 0;
    padding: 14px 20px calc(28px + env(safe-area-inset-bottom, 0px));
    /* The second shadow continues the sheet's background downwards: when it is
       pulled up (Matan, 11.10) no empty gap opens under it. A shadow and not
       `::after`: the sheet scrolls, and whatever is outside it is clipped. */
    box-shadow: 0 160px 0 0 var(--color-bg-elevated), 0 -12px 50px rgba(20, 16, 7, 0.25);
    transform: translateY(60px);
    /* Rises and stops smoothly, without overshooting (Matan, 7.10, Apple-style,
       item 4). A bounce is reserved for motion that had the finger's momentum;
       tapping + isn't like that. The curve of iPhone sheets. The pull down
       manages its own motion in JS. */
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-overlay.open .modal-sheet {
    transform: translateY(0);
}

.modal-handle {
    width: 44px;
    height: 4px;
    border-radius: var(--radius-pill);
    background: rgba(var(--ink-rgb), 0.15);
    margin: 0 auto 16px;
}

.modal-close {
    position: absolute;
    top: 16px;
    inset-inline-end: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-input);
    color: var(--color-text-muted);
    font-size: var(--text-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 700;
}

/* Type toggle */
.type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--color-input);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 4px;
    gap: 4px;
}

.type-toggle-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.toggle-btn {
    padding: 9px 0;
    border-radius: var(--radius-sm);
    font-size: var(--text-body);
    font-weight: 600;
    color: var(--color-text-muted);
    transition: all 0.2s, transform 120ms ease-out;
}
.toggle-btn:active:not(:disabled) { transform: scale(0.97); }

/* One segmented control in the whole app (design pass, 11.11, Matan saw it side
   by side): the chosen option is a white pill on the grey track, like "של מי"
   and the date in the add sheet. It was a full gold, red or green block that
   outshouted the amount itself. The type keeps its colour, in the text. */
.toggle-btn.active {
    background: var(--color-card);
    color: var(--color-gold-text);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(31, 24, 8, 0.12);
}

.modal-sheet.income-mode .toggle-btn.active,
.cat-type-tabs .toggle-btn[data-cat-tab="income"].active,
.project-cat-tabs .toggle-btn[data-cat-tab="income"].active { color: var(--color-income); }

.modal-sheet.expense-mode .toggle-btn.active,
.cat-type-tabs .toggle-btn[data-cat-tab="expense"].active,
.project-cat-tabs .toggle-btn[data-cat-tab="expense"].active { color: var(--color-expense); }

.modal-sheet.savings-mode .toggle-btn.active { color: var(--color-savings); }

/* Owner toggle: whose expense it is */
.owner-toggle {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
}

.owner-btn {
    padding: 10px 4px;
    border-radius: var(--radius-sm);
    background: var(--color-card);
    border: 1px solid rgba(var(--ink-rgb), 0.10);
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--color-text-soft);
    transition: all var(--dur-quick);
}

.owner-btn.active {
    background: var(--color-gold-dim);
    border-color: var(--color-gold);
    color: var(--color-gold-text);
    font-weight: 700;
}

/* Scan button */
.scan-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    background: var(--color-gold-dim);
    border: 1px dashed var(--color-gold-border);
    color: var(--color-gold-text);
    font-weight: 600;
    font-size: var(--text-body);
}

.scan-btn:disabled { opacity: 0.6; }

/* Scanner animation */
.scanner-wrapper {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.scanner-wrapper.active { display: flex; }

.scanner-frame {
    position: relative;
    width: 150px;
    height: 100px;
    border-radius: var(--radius-sm);
    background: var(--color-gold-dim);
    overflow: hidden;
}

.scanner-thumbnail {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.55;
}

.scanner-line {
    position: absolute;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--color-gold);
    box-shadow: 0 0 12px rgba(166, 124, 0, 0.6);
    animation: scan 1.4s ease-in-out infinite alternate;
}

@keyframes scan {
    from { top: 10%; }
    to   { top: 88%; }
}

.scanner-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--color-gold);
    border-style: solid;
    border-width: 0;
}

.scanner-corner.tl { top: 6px;    right: 6px; border-top-width: 2px; border-right-width: 2px; border-radius: 0 6px 0 0; }
.scanner-corner.tr { top: 6px;    left: 6px;  border-top-width: 2px; border-left-width: 2px;  border-radius: 6px 0 0 0; }
.scanner-corner.bl { bottom: 6px; right: 6px; border-bottom-width: 2px; border-right-width: 2px; border-radius: 0 0 6px 0; }
.scanner-corner.br { bottom: 6px; left: 6px;  border-bottom-width: 2px; border-left-width: 2px;  border-radius: 0 0 0 6px; }

.scanner-label {
    font-size: var(--text-sm);
    color: var(--color-gold-text);
    font-weight: 500;
}

/* ─── Forms ───────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-soft);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--color-card);
    /* 0.5 and not 0.14: the field's edge at 3:1 against the card (1.3 before),
       so it reads in sunlight too (Matan, 11.11, from the samples) */
    border: 1px solid rgba(var(--ink-rgb), 0.5);
    color: var(--color-text);
    font-size: var(--text-base);
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(166, 124, 0, 0.14);
}

.form-input::placeholder {
    /* #A8A29E was 2.2:1 on the input fill; the muted text colour passes (5.1) */
    color: var(--color-text-muted);
}

select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2378716C' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-left: 38px;
}

input[type="date"].form-input {
    min-height: 48px;
    color-scheme: light;
}

/* Hide number-input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Amount input */
/* "Today/yesterday" chips in the date picker */
.date-quick-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.date-chip {
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-soft);
    background: var(--color-input);
    border: 1px solid transparent;
}

.date-chip.active {
    color: var(--color-gold-text);
    background: var(--color-gold-dim);
    border-color: var(--color-gold-border);
}

.amount-input-wrap {
    position: relative;
}

.amount-currency {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-gold-text);
    font-weight: 700;
    font-size: var(--text-title);
    pointer-events: none;
}

.amount-input {
    padding-inline-start: 38px;
    font-size: var(--text-xl);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Category grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.cat-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px;
    border-radius: var(--radius-sm);
    background: var(--color-card);
    border: 1px solid rgba(var(--ink-rgb), 0.10);
    font-size: var(--text-2xs);
    font-weight: 500;
    color: var(--color-text-soft);
    transition: all var(--dur-quick);
}

.cat-btn .cat-emoji {
    font-size: var(--text-lg);
}

.cat-btn.active {
    background: var(--color-gold-dim);
    border-color: var(--color-gold);
    color: var(--color-gold-text);
    font-weight: 700;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-xs);
    border: 1.5px solid rgba(var(--ink-rgb), 0.25);
    background: var(--color-card);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-quick);
}

.checkbox-input:checked + .checkbox-custom {
    background: var(--gradient-gold);
    border-color: var(--color-gold);
}

.checkbox-input:checked + .checkbox-custom::after {
    content: '✓';
    color: #FFFFFF;
    font-size: var(--text-sm);
    font-weight: 700;
}

.checkbox-text {
    font-size: var(--text-body);
    font-weight: 500;
}

/* Recurring fields */
.recurring-fields {
    display: none;
    margin-top: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--color-gold-dim);
    border: 1px solid rgba(166, 124, 0, 0.16);
}

.recurring-fields.visible { display: block; }

.recurring-fields .form-group:last-child { margin-bottom: 0; }
/* "החודש זו הפעם האחרונה", under the end date: a text button, as wide as its words */
.tx-last-time { display: block; margin-top: 4px; padding: 8px 0; min-height: 36px; text-align: start; }
.tx-last-time[hidden] { display: none; }
.tx-last-time:disabled { color: var(--color-text-muted); cursor: default; }

/* Errors */
.form-error {
    color: var(--color-expense);
    font-size: var(--text-md);
    font-weight: 500;
    min-height: 1.2em;
    margin-bottom: 8px;
}

/* Submit */
.submit-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--gradient-gold);
    color: #FFFFFF;
    font-size: var(--text-base);
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: var(--shadow-gold);
    transition: transform 0.15s, opacity 0.15s;
}

.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled,
.submit-btn.is-busy { opacity: 0.6; }

/* The modal's save button is a <label> (see the note in the template): it needs
   what a <button> gives for free: layout, centring, and a hand cursor */
label.submit-btn {
    display: block;
    text-align: center;
    cursor: pointer;
    border: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

label.submit-btn.is-busy { cursor: default; }
/* An eye for showing the password (`js/password-eye.js`, Matan 12.10). The
   field gets room for the button on the left (RTL: the end of the field), and
   the button sits on it. */
.pw-wrap { position: relative; display: block; }
.pw-wrap > .form-input { padding-inline-end: 46px; }
.pw-eye {
    position: absolute; inset-inline-end: 4px; top: 50%; translate: 0 -50%;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    background: none; border: 0; border-radius: var(--radius-sm); color: var(--color-text-muted); cursor: pointer;
}
.pw-eye svg { width: 20px; height: 20px; }
.pw-eye[aria-pressed="true"] { color: var(--color-gold-text); }

/* Sorting "all transactions" (Matan, 12.10) */
.tx-sort-chips { display: flex; align-items: center; gap: 6px; margin: 2px 0 8px; }
.tx-sort-label { font-size: var(--text-sm); color: var(--color-text-muted); }

/* "הבא: 1.11" in the recurring transactions list (Matan, 12.10) */
.recurring-next { margin: 1px 0 0; font-size: var(--text-2xs); color: var(--color-text-muted); }

/* "Part of a recurring transaction" at the top of the edit sheet (Matan, 12.10) */
.tx-series-link {
    display: flex; align-items: center; gap: 6px; margin: -4px 0 10px;
    font-size: var(--text-sm); font-weight: 600; color: var(--color-gold-text); text-decoration: none;
}
.tx-series-link[hidden] { display: none; }
/* A charge of a recurring transaction: what it is, and the two things one does
   with the series (Matan, 29.11) */
.tx-series-box {
    margin: 0 0 14px; padding: 12px; border-radius: var(--radius-sm);
    background: var(--color-gold-dim); border: 1px solid rgba(166, 124, 0, 0.22);
}
.tx-series-box[hidden], .tx-series-note[hidden], .tx-series-btn[hidden] { display: none; }
.tx-series-label {
    display: flex; align-items: center; gap: 6px; margin: 0 0 10px;
    font-size: var(--text-md); font-weight: 600; color: var(--color-text-soft);
}
.tx-series-label .ui-icon { color: var(--color-gold-text); }
.tx-series-actions { display: flex; gap: 8px; }
/* No action for this charge (another month's): the label alone, with no gap under it */
.tx-series-box.is-bare .tx-series-label { margin-bottom: 0; }
.tx-series-box.is-bare .tx-series-actions { display: none; }
.tx-series-btn {
    flex: 1 1 0; min-width: 0; min-height: var(--btn-h-md); padding: 6px 8px;
    border: 1px solid rgba(166, 124, 0, 0.32); border-radius: var(--radius-sm);
    background: var(--color-card); color: var(--color-gold-text);
    font: inherit; font-size: var(--text-md); font-weight: 600; cursor: pointer;
}
.tx-series-btn:disabled { opacity: 0.6; cursor: default; }
/* The series open for editing: one line on what a change here does */
.tx-series-note { margin: -4px 0 14px; font-size: var(--text-md); color: var(--color-text-muted); }

/* Editing with no change: the button is grey, same label (Matan, 12.10; 13.10) */
label.submit-btn.is-unchanged,
#modalOverlay label.submit-btn.is-unchanged,
:root[data-theme="dark"] #modalOverlay label.submit-btn.is-unchanged {
    background: var(--color-input); color: var(--color-text-muted); box-shadow: none; cursor: default;
}

/* The real submit control, hidden: exists only so Enter inside a field submits
   the form */
.submit-fallback {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

a.submit-btn {
    display: block;
    text-decoration: none;
    text-align: center;
}

.error-card { text-align: center; }
.error-card .empty-illus { margin-bottom: 8px; }
.error-message { text-align: center; margin-bottom: 20px; }



/* The edit-mode action row: "add again" + "delete" side by side */
/* Suggestions from earlier descriptions under the description field (Matan,
   3.10, idea 41) */
.desc-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.desc-suggest[hidden] { display: none; }
.desc-suggest-item {
    border: 1px solid var(--color-gold-border); background: var(--color-gold-dim); color: var(--color-gold-text);
    border-radius: var(--radius-pill); padding: 6px 12px; font-size: var(--text-sm); font-weight: 600; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* "הוזנה ע״י אור · אתמול 18:32": in the edit sheet's header row (Matan, 3.10 / 5.10) */
.tx-entered-meta { margin: 0; text-align: end; font-size: var(--text-2xs); line-height: 1.3; color: var(--color-text-muted); max-width: 45%; }
.tx-entered-meta[hidden] { display: none; }
/* "Continuing what you filled in" + clear, on a draft that came back (Matan, 22.11) */
.tx-draft-note {
    margin: 8px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 4px 6px 4px 12px; border-radius: var(--radius-sm, 12px);
    background: var(--color-input); font-size: var(--text-md); color: var(--color-text-soft);
}
.tx-draft-note[hidden] { display: none; }
.tx-draft-clear {
    border: 0; background: transparent; font: inherit; font-weight: 600;
    color: var(--color-gold-text); min-height: 36px; padding-inline: 10px; cursor: pointer;
}

.edit-mode-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.duplicate-tx-btn,
.delete-tx-btn {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--text-body);
    text-align: center;
}

.duplicate-tx-btn {
    background: var(--color-input);
    border: 1px solid transparent;
    color: var(--color-text-soft);
}

.delete-tx-btn {
    background: rgba(185, 28, 28, 0.07);
    border: 1px solid rgba(185, 28, 28, 0.22);
    color: var(--color-expense);
}

.delete-tx-btn:disabled { opacity: 0.6; }

/* ─── Income and savings: a donut like expenses (Matan, 30.9) ─────── */
/* Expenses in the expense colour (design pass, 11.11): gold is savings everywhere else */
.doughnut-total.expense { color: var(--color-expense); }
.doughnut-total.income  { color: var(--color-income); }
.doughnut-total.savings { color: var(--color-savings); }

/* Savings: the total at the top of the card, no chart */
.savings-total {
    text-align: center;
    padding: 2px 0 14px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(var(--ink-rgb), 0.07);
}

.savings-total-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.savings-total-value {
    font-size: var(--text-display);
    font-weight: 700;
    color: var(--color-savings);
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

.savings-of-income {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ─── Months comparison ───────────────────────────────────────── */
/* One table: a row per month, a column per type (Matan, 30.9) */


.months-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: var(--text-xs);
}

.months-table col.c-month   { width: 23%; }
.months-table col.c-balance { width: 24%; }

.months-table th {
    font-weight: 500;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-align: start;
    padding: 9px 2px;
}

.months-table td {
    padding: 12px 2px;
    border-top: 1px solid rgba(var(--ink-rgb), 0.07);
    white-space: nowrap;
}

.months-table .n {
    text-align: left;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.months-table th.n { direction: rtl; font-weight: 500; text-align: left; }   /* above its numbers */

.months-table td.m { font-weight: 700; font-size: var(--text-md); overflow: hidden; text-overflow: ellipsis; }
.months-table td.m a { color: inherit; text-decoration: none; }

.months-table .inc { color: var(--color-income); }
.months-table .exp { color: var(--color-expense); }
.months-table .sav { color: var(--color-savings); }
.months-table .bal { font-weight: 700; }
.months-table .bal.surplus { color: var(--color-income); }
.months-table .bal.deficit { color: var(--color-expense); }

/* A card per year: the year at its top, and the table below. A previous year
   is collapsed: a card with the year only, and tapping it opens it */
.year-block.chart-card { padding: 0; overflow: hidden; margin-bottom: 12px; }

.year-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    min-height: 52px;
    font-size: var(--text-title);
    font-weight: 700;
    color: var(--color-gold-text);
    letter-spacing: 0.04em;
    cursor: pointer;
    list-style: none;
}

.year-title::-webkit-details-marker { display: none; }
.year-block[open] > .year-title { border-bottom: 1px solid rgba(var(--ink-rgb), 0.07); }

.year-chevron { display: flex; color: var(--color-gold-text); transition: transform 0.2s; }
.year-chevron svg { width: 18px; height: 18px; }
.year-block[open] > .year-title .year-chevron { transform: rotate(180deg); }

.months-table-wrap { padding: 0 12px 8px; }

.months-table .month-row { cursor: pointer; }
.months-table .month-row:active td { background: var(--color-card-hover); }

.current-month-badge {
    display: block;
    width: fit-content;
    margin-top: 2px;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-gold-text);
    background: var(--color-gold-dim);
    padding: 1px 6px;
    border-radius: var(--radius-pill);
}


/* ─── Charts & KPI (light cards) ──────────────────────────────── */

.kpi-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.kpi-value {
    font-weight: 700;
    font-size: var(--text-base);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    white-space: nowrap;
}

.kpi-value.surplus { color: var(--color-income); }
.kpi-value.deficit { color: var(--color-expense); }
.kpi-value.income  { color: var(--color-income); }
.kpi-value.expense { color: var(--color-expense); }
.kpi-value.savings { color: var(--color-savings); }

.chart-card {
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
}

.chart-title {
    font-size: var(--text-base);
    font-weight: 700;
    margin-bottom: 16px;
}

.cat-manage-bar .chart-title { margin-bottom: 0; }

.wealth-bucket-hint {
    font-size: var(--text-2xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

.chart-empty {
    text-align: center;
    padding: 30px 0;
    color: var(--color-text-muted);
    font-size: var(--text-body);
}


/* Doughnut */
.doughnut-wrap {
    position: relative;
    max-width: 230px;
    margin: 0 auto 16px;
}

.doughnut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.doughnut-total {
    font-size: var(--text-xl);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-gold-text);
    direction: ltr;
}

.doughnut-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* When the chart library didn't load: the canvas is replaced with a message,
   and the number that floated in the middle of the donut returns to the normal
   flow; otherwise it falls onto the text. */
.chart-unavailable {
    max-width: none;
    height: auto;
}

.chart-unavailable .doughnut-center {
    position: static;
    pointer-events: auto;
}

/* Legend */
.legend-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-md);
    padding: 6px 4px;
    border-bottom: 1px solid var(--divider-subtle);
}

.legend-item:last-child { border-bottom: none; }

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-pct {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    min-width: 36px;
    text-align: left;
}

.legend-amount {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    white-space: nowrap;
}

/* ── Expandable category rows ── */

.legend-item-wrap {
    border-bottom: 1px solid var(--divider-subtle);
}

.legend-item-wrap:last-child { border-bottom: none; }

.legend-item-wrap .legend-item { border-bottom: none; }

.legend-item.clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.expand-chevron {
    display: inline-flex;
    align-items: center;
    color: var(--color-text-muted);
    transition: transform 0.25s;
    vertical-align: middle;
}

.expand-chevron svg { width: 14px; height: 14px; }

.legend-item-wrap.open .expand-chevron {
    transform: rotate(180deg);
}

.cat-tx-list {
    display: none;
    margin: 2px 0 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--color-input);
}

/* A standalone list (not a collapsible drilldown), e.g. on a single project page */
/* The project page: the last 5, and the rest behind "show all transactions" */
#projectTxList:not(.show-all) .tx-extra { display: none; }

.show-all-tx {
    display: block;
    width: 100%;
    margin-top: 10px;
    min-height: 44px;
}

.cat-tx-list.cat-tx-list-standalone {
    display: block;
    background: none;
    padding: 0;
    margin: 0;
}

.legend-item-wrap.open .cat-tx-list {
    display: block;
}

.tx-search-wrap { margin: 4px 0 10px; }
.tx-search-input { font-size: 1rem; padding: 9px 12px; }
.tx-type-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tx-type-chip { min-height: 36px; }
/* The category row under the type (Matan, 30.9): scrolls sideways when there are
   many */
.tx-cat-chips {
    display: flex; gap: 8px; margin-bottom: 8px;
    overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
}
.tx-cat-chips[hidden] { display: none; }
.tx-cat-chips::-webkit-scrollbar { display: none; }
.tx-cat-chip { flex: none; white-space: nowrap; min-height: 34px; padding: 6px 12px; font-size: var(--text-sm); }
/* The category shown in the "expenses by category" chart on the comparison
   page: highlighted, so it is clear which one is on screen (Matan, 3.10) */
/* Expenses by family member over the months (Matan, 3.10, idea 15) */
.line-chart-wrap.member-trend-wrap { height: 230px; }
.member-trend-avgs { margin: 10px 0 0; font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; }

/* The chart range on the comparison page (Matan, 3.10, idea 24) */
.range-chips { display: flex; gap: 6px; margin: 4px 0 10px; }
.range-chips[hidden] { display: none; }
.range-chip { padding: 5px 12px; font-size: var(--text-xs); position: relative; }

.cat-trend-chips .tx-cat-chip.active {
    background: var(--gradient-gold); color: #FFFFFF; border-color: transparent;
    font-weight: 700; box-shadow: 0 2px 8px rgba(166, 124, 0, 0.28);
}
.tx-cat-chip-amount {
    margin-inline-start: 5px; font-weight: 500; color: var(--color-text-muted);
    font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate;
}
.tx-search-empty {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    text-align: center;
    padding: 12px 0 4px;
}

.cat-tx-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    margin: 0 -4px;
    border-radius: var(--radius-xs);
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--divider-subtle);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}

.cat-tx-row:last-child { border-bottom: none; }

.cat-tx-row:active {
    background: rgba(var(--ink-rgb), 0.05);
}

.cat-tx-date {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    min-width: 38px;
    direction: ltr;
    text-align: right;
}

.cat-tx-desc {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-soft);
}

/* "הוזנה ע״י אור": in a project that went back to being personal. Secondary
   information, not a tag: the coloured tag already says "whose money", and this
   is something else. */
.tx-entered-by {
    color: var(--color-text-muted);
    font-size: 0.85em;
}

.cat-tx-amount {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    white-space: nowrap;
}

.cat-tx-amount.expense { color: var(--color-expense); }
.cat-tx-amount.income  { color: var(--color-income); }
.cat-tx-amount.savings { color: var(--color-savings); }

/* categories with no activity: collapsed */
.zero-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 0 4px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.zero-toggle .expand-chevron svg { width: 13px; height: 13px; }

.zero-toggle.open .expand-chevron { transform: rotate(180deg); }

li.zero-cat-row { display: none; }

.legend-list.show-zeros li.zero-cat-row { display: block; }

.zero-cat-row .legend-item { opacity: 0.6; }

.legend-dot-zero { background: rgba(var(--ink-rgb), 0.18); }

/* all transactions */
.all-tx-count {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-gold-text);
    background: var(--color-gold-dim);
    border-radius: var(--radius-pill);
    padding: 2px 10px;
}


/* Chart wrapper (doughnut / bar / line canvases) */
.line-chart-wrap {
    position: relative;
    height: 240px;
}

/* The chart fills its container's full width. A Safari RTL bug: a canvas at
   width 300 (the default) inside a wider container gets, in getComputedStyle,
   a left margin the size of the difference, and Chart.js subtracts it, so the
   chart is stuck at 300 forever, and the whole left side of the card stays empty
   (Matan's screenshot, 30.9). Chrome returns 0 and doesn't show it. Width 100%
   removes the difference, and with it the phantom margin. */
.line-chart-wrap canvas,
.doughnut-wrap canvas {
    width: 100% !important;
}

/* The comparison page: the chart is wide (to the card's edges), not taller
   (Matan, 30.9) */
.line-chart-wrap.compare-chart-wrap { margin-inline: -10px; }

/* ─── Settings: accordion groups ──────────────────────────────── */

.settings-groups {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-group {
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    /* An opening that closes a box above it scrolls here: not under the clock/island
   on iPhone */
    scroll-margin-top: calc(14px + env(safe-area-inset-top, 0px));
}

.settings-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    /* One row since the line under the title was removed (Matan, 11.10). It was
       shrunk then so everything fits on one screen, and looked too short; it was
       widened again (Matan, 13.10) */
    padding: 14px 17px;
    text-align: right;
    -webkit-tap-highlight-color: transparent;
}

.group-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--color-gold-dim);
    color: var(--color-gold-text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.group-icon svg { width: 20px; height: 20px; }

.group-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.group-title {
    font-weight: 600;
    font-size: var(--text-base);
}

.group-chevron {
    color: var(--color-text-muted);
    display: flex;
    transition: transform 0.25s;
    flex-shrink: 0;
}

.group-chevron svg { width: 16px; height: 16px; }

.settings-group.open .group-chevron { transform: rotate(180deg); }

.settings-group-body {
    display: none;
    padding: 4px 16px 16px;
    border-top: 1px solid var(--divider-subtle);
}

.settings-group.open .settings-group-body { display: block; }

.group-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.group-row-info { flex: 1; min-width: 0; }

.group-row-label {
    font-weight: 600;
    font-size: var(--text-body);
}

.group-row-value {
    font-size: var(--text-md);
    color: var(--color-text-soft);
}

.group-row-hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.group-divider {
    height: 1px;
    background: rgba(var(--ink-rgb), 0.06);
    margin: 8px 0;
}

/* Categories management inside the group */
.cat-manage-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0 12px;
}

.cat-manage-bar .cat-type-tabs { flex: 1; }

/* Normal mode: clean rows: the edit/delete/reorder and add buttons are hidden */
#categoriesArea:not(.managing) .edit-cat-btn,
#categoriesArea:not(.managing) .delete-cat-btn,
#categoriesArea:not(.managing) .cat-reorder-btns,
#categoriesArea:not(.managing) .cat-drag-handle,
#categoriesArea:not(.managing) #addCatForm,
#categoriesArea:not(.managing) #restoreDefaultsRow,
#projectCategoriesArea:not(.managing) .edit-cat-btn,
#projectCategoriesArea:not(.managing) .delete-cat-btn,
#projectCategoriesArea:not(.managing) #addProjectCatForm {
    display: none;
}

.cat-reorder-btns {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.cat-move-btn {
    position: relative;
    width: 30px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    border-radius: 4px;
}

.cat-move-btn svg { width: 12px; height: 12px; }

/* A hidden tap area. The button itself is 30×15 because the two arrows sit
   right on top of each other, and a large symmetric area would overlap between
   them, making a miss trigger the opposite direction, i.e. worse than nothing.
   The fix is for each to expand *in its own direction*: the upper arrow
   upwards, the lower one downwards. That way both reach 26px without touching
   each other, above the minimum of 24 the standard asks for. */
.cat-move-btn::before {
    content: '';
    position: absolute;
    left: 50%;
    width: 44px;
    height: 26px;
    transform: translateX(-50%);
}

.cat-move-up::before   { bottom: 0; }   /* expands upwards */
.cat-move-down::before { top: 0; }      /* expands downwards */

.cat-move-btn:disabled {
    opacity: 0.25;
    pointer-events: none;
}

#addCatForm {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(166, 124, 0, 0.25);
}

#addCatForm .add-cat-row { margin-bottom: 6px; }
#addCatForm .btn-primary { padding: 0 16px; white-space: nowrap; }

/* ─── Settings ────────────────────────────────────────────────── */

.settings-card {
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-card);
}



.family-name-edit {
    display: none;
    margin-top: 14px;
}

.family-name-edit.visible { display: block; }

.edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-sm {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    font-weight: 600;
}
/* A link that looks like a button ("cancel" on the new-project screen returns
   to the list) */
.btn-sm { transition: transform 120ms ease-out; }
.btn-sm:active:not(:disabled) { transform: scale(0.97); }   /* press feedback; see `.nav-icon` */
a.btn-sm { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.btn-primary {
    background: var(--gradient-gold);
    color: #FFFFFF;
}

.btn-ghost {
    background: var(--color-input);
    color: var(--color-text-soft);
}

.invite-code-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.invite-code-value {
    font-family: monospace;
    font-size: var(--text-xs);
    color: var(--color-gold-text);
    direction: ltr;
    word-break: break-all;
}

/* Members */
.members-settings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.member-settings-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 4px 0;
}

.member-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-gold);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-md);
    flex-shrink: 0;
}

.member-settings-info {
    flex: 1;
    min-width: 0;
}

.member-settings-name {
    font-weight: 600;
    font-size: var(--text-body);
}

.member-settings-meta {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.me-badge {
    display: inline-block;
    font-size: var(--text-2xs);
    font-weight: 700;
    color: var(--color-gold-text);
    background: var(--color-gold-dim);
    border-radius: var(--radius-pill);
    padding: 1px 8px;
    margin-inline-start: 4px;
    vertical-align: middle;
}

/* The family manager tag: one single role in the family: whoever may remove
   members. Grey and not gold, so it doesn't compete with "me" next to it. */
.manager-badge {
    display: inline-block;
    font-size: var(--text-2xs);
    font-weight: 700;
    color: var(--color-text-muted);
    background: var(--color-input);
    border-radius: var(--radius-pill);
    padding: 1px 8px;
    margin-inline-start: 4px;
    vertical-align: middle;
}

/* Recurring transactions */
.recurring-list {
    display: flex;
    flex-direction: column;
}

.recurring-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--divider-subtle);
}

.recurring-row:first-child { padding-top: 0; }
.recurring-row:last-child  { border-bottom: none; padding-bottom: 0; }

.recurring-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--color-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-title);
    flex-shrink: 0;
}

.recurring-details { flex: 1; min-width: 0; }

.recurring-name {
    font-weight: 600;
    font-size: var(--text-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* "₪5,000 ← ₪5,500 מאוקטובר" (Matan, 3.10, idea 40) */
.recurring-price-change { font-size: var(--text-2xs); color: var(--color-text-muted); margin-top: 1px; font-variant-numeric: tabular-nums; }

.recurring-amount {
    font-weight: 700;
    font-size: var(--text-body);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    white-space: nowrap;
}

.recurring-amount.income  { color: var(--color-income); }
.recurring-amount.expense { color: var(--color-expense); }
.recurring-amount.savings { color: var(--color-savings); }

/* Summary and groups (Matan, 11.10, option A): how much comes in, goes out and
   is saved every month */
.recurring-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 6px;
}
.recurring-sum {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 6px;
    border-radius: var(--radius-sm);
    background: var(--color-input);
    text-align: center;
}
.recurring-sum-label { font-size: var(--text-2xs); color: var(--color-text-muted); }
.recurring-sum-value {
    font-weight: 700;
    font-size: var(--text-base);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.recurring-sum-value.income  { color: var(--color-income); }
.recurring-sum-value.expense { color: var(--color-expense); }
.recurring-sum-value.savings { color: var(--color-savings); }

/* The two parts of the list: "קבועות" and "בתשלומים" (Matan, 22.11) */
.recurring-part-title { margin: 6px 0 2px; font-size: var(--text-base); font-weight: 700; color: var(--color-text); }
.recurring-part-title.has-line { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(var(--ink-rgb), 0.12); }
.recurring-group-title {
    margin: 14px 0 8px;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--color-text-muted);
}
.recurring-row { cursor: pointer; }
.recurring-chevron { display: flex; color: var(--color-text-muted); opacity: 0.6; }
.recurring-chevron svg { width: 16px; height: 16px; }

/* Categories management */
.categories-list {
    display: flex;
    flex-direction: column;
}

.category-row {
    display: flex;
    /* The row wraps so the budget block gets its own line under the name */
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--divider-subtle);
}

.category-row:first-child { padding-top: 0; }
.category-row:last-child  { border-bottom: none; padding-bottom: 0; }

.cat-row-icon { font-size: var(--text-title); }

.cat-row-name {
    flex: 1;
    font-weight: 500;
    font-size: var(--text-body);
}

/* "₪1,850 a month on average" under the name (Matan, 3.10, idea 38) */
.cat-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cat-row-text .cat-row-name { flex: none; }
.cat-row-avg { font-size: var(--text-2xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }


.edit-cat-btn {
    position: relative;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--color-input);
    color: var(--color-gold-text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.edit-cat-btn svg { width: 14px; height: 14px; }

.category-row.editing {
    gap: 8px;
}

.category-row.editing .form-input {
    padding: 8px 10px;
    font-size: 1rem;
}

.category-row.editing .cat-edit-icon { width: 52px; }
.category-row.editing .cat-edit-name { flex: 1; min-width: 0; }
.category-row.editing .btn-sm { padding: 8px 12px; white-space: nowrap; }

.delete-cat-btn {
    position: relative;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: rgba(185, 28, 28, 0.08);
    color: var(--color-expense);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* A "belongs to a project" tag on a transaction row in lists */
.project-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: var(--text-2xs);
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-input);
    border-radius: var(--radius-pill);
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The "projects this month" section: amounts */
.pm-amount {
    font-variant-numeric: tabular-nums;
    direction: ltr;
    font-weight: 700;
}
.pm-amount.expense { color: var(--color-expense); }
.pm-amount.income  { color: var(--color-income); }
.pm-amount.savings { color: var(--color-savings); }

/* Add category */
.add-cat-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.emoji-input {
    width: 62px;
    text-align: center;
    font-size: var(--text-lg);
    flex-shrink: 0;
}

.add-cat-form select { margin-bottom: 12px; }

/* Account */
.member-avatar-lg {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gradient-gold);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-lg);
    flex-shrink: 0;
}

.account-edit {
    display: none;
    margin-bottom: 16px;
    padding-top: 4px;
}

.account-edit.visible { display: block; }

.form-success {
    color: var(--color-income);
    font-size: var(--text-md);
    font-weight: 500;
    min-height: 1.2em;
    margin-bottom: 8px;
}

.password-form {
    display: none;
    margin-top: 14px;
}

.password-form.visible { display: block; }

/* Deleting the account: danger zone */
/* "Advanced options" in settings: rare actions that shouldn't be within easy reach */
.advanced-options > .advanced-summary {
    cursor: pointer;
    padding: 12px 0;
    font-size: var(--text-md);
    color: var(--color-text-muted);
    list-style-position: inside;
}

.btn-danger-ghost {
    color: var(--color-expense);
    border: 1px solid rgba(185, 28, 28, 0.25);
    background: rgba(185, 28, 28, 0.05);
}

.btn-danger {
    background: var(--gradient-danger);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.25);
}

.delete-account-warning {
    font-size: var(--text-sm);
    line-height: 1.55;
    color: var(--color-expense);
    background: var(--alert-danger-bg);
    border-inline-start: 3px solid var(--color-expense);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 14px;
}

.logout-btn {
    display: block;
    text-align: center;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(185, 28, 28, 0.07);
    border: 1px solid rgba(185, 28, 28, 0.22);
    color: var(--color-expense);
    font-weight: 600;
    font-size: var(--text-body);
    text-decoration: none;
    /* The button was an <a> and became a <button> inside a POST form (CSRF
       protection), so it needs what an <a> got for free */
    width: 100%;
    font-family: inherit;
    cursor: pointer;
}

.logout-form { margin: 0; }
/* below all the boxes, not inside "account" (Matan, 1.10) */
.settings-logout { margin-top: 12px; }

/* A heading with an action at its side (e.g. "all transactions" + export) */
.chart-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.chart-title-row .chart-title { margin-bottom: 0; }
.export-link { text-decoration: none; white-space: nowrap; }

/* A label that exists for the screen reader and not the eye.
   `display:none` would hide it from the screen reader too, i.e. do nothing. The
   combination here is the accepted pattern: the element exists, one pixel in
   size, and clipped. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* The category budget: always visible, with no "management mode".
 *
 * It used to be hidden behind the same toggle that hides editing, deleting and
 * reordering, and rightly so for those: they are actions on the list itself. But
 * a budget isn't list management, it is the setting people install a budgeting
 * app for in the first place. Hiding it behind an unlabelled button means most
 * users won't know it exists.
 *
 * `flex-wrap` on the row is what drops the block onto its own line instead of
 * squeezing it next to the name. */
/* Since 11.11 (design pass) the label and switch sit on the category's own row:
   the block's children join the row, and only the amount fields wrap below. */
/* The budget on a category's row: what it is, and a way to the sheet that sets
   it (Matan, 22.11) */
.cat-budget-link {
    display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding-inline: 6px;
    font-size: var(--text-md); font-weight: 600; color: var(--color-text-muted); text-decoration: none; white-space: nowrap;
}
.cat-budget-link.has-budget { color: var(--color-gold-text); }
.cat-budget-link svg { width: 14px; height: 14px; }
#categoriesArea.managing .cat-budget-link { display: none; }

/* ─── A target budget per category ──────────────────────────────── */

.cat-budget { padding: 2px 0 10px; }

.cat-budget-text {
    margin: 4px 0 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* How much of the budget is used, under the sentence (Matan, 24.11) */
.cat-budget-bar {
    display: block;
    height: 4px;
    margin-top: 6px;
    border-radius: var(--radius-pill);
    background: rgba(var(--ink-rgb), 0.08);
    overflow: hidden;
}
.cat-budget-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--color-gold);
}
.cat-budget.over .cat-budget-bar > span { background: var(--color-expense); }

/* A quiet action beside a heading: text, not a button (Matan, 24.11) */
/* A 44px tap area around the short text button (audit, 1.12: 32px high) */
.title-link { position: relative; }
.title-link::before { content: ""; position: absolute; inset: -6px 0; }
.title-link {
    border: 0;
    background: none;
    padding: 6px 0;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-gold-text);
    cursor: pointer;
}

/* overage: the sentence in red */
.cat-budget.over .cat-budget-text { color: var(--color-expense); font-weight: 600; }

/* ─── Projects this month ────────────────────────────────────────── */

/* A row per project, in the same pattern as the categories. The amounts are
   kept separately by type and not netted, so a row for a two-way project holds
   two numbers. */
.legend-amount .pm-amount { margin-inline-start: 6px; font-variant-numeric: tabular-nums; }
.legend-amount .pm-amount:first-child { margin-inline-start: 0; }

.cat-tx-more { justify-content: flex-start; padding-top: 10px; }
.cat-tx-more a { font-size: var(--text-sm); color: var(--color-gold-text); text-decoration: none; font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .cat-tx-more a:hover { text-decoration: underline; } }

/* ─── Auth pages (dark fintech) ───────────────────────────────── */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    /* In the app installed on iPhone (black-translucent) the page is also painted
       under the clock and the dynamic island; without the spacing the start of a
       long form hides there */
    padding: calc(24px + env(safe-area-inset-top, 0px)) 16px
             calc(24px + env(safe-area-inset-bottom, 0px));
    /* A height that doesn't move (Matan, 4.12: the sign-in page jumped up and
       down while iPhone's password autofill was open). `100dvh` follows the
       screen's changing height, and this page centers its card in it: every
       change moved the card, and the move changed the height again. `100svh` is
       the screen's smallest height, fixed; the same lesson as `body` above
       (`100lvh`, 30.9). */
    min-height: 100vh;
    min-height: 100svh;
    background:
        radial-gradient(ellipse 90% 50% at 80% -10%, rgba(212, 175, 55, 0.14), transparent 55%),
        linear-gradient(160deg, var(--hero-bg-2) 0%, var(--hero-bg) 70%);
    background-image:
        radial-gradient(ellipse 90% 50% at 80% -10%, rgba(212, 175, 55, 0.14), transparent 55%),
        linear-gradient(160deg, var(--hero-bg-2) 0%, var(--hero-bg) 70%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42'%3E%3Ccircle cx='1' cy='1' r='1' fill='%23FFF8E7' fill-opacity='0.05'/%3E%3C/svg%3E");
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-hero {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(212, 175, 55, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gold-bright);
}

.auth-logo-icon svg {
    width: 28px;
    height: 28px;
}

.auth-trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 14px;
    font-size: var(--text-xs);
    color: var(--hero-text-muted);
}

.auth-trust svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.auth-app-name {
    font-size: 1.9rem;
    font-weight: 700;
    background: var(--gradient-gold-text);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.01em;
}

.auth-tagline {
    color: var(--hero-text-muted);
    font-size: var(--text-body);
    margin-top: 4px;
}

.auth-form-card {
    position: relative;
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: 28px 22px 24px;
    box-shadow: var(--shadow-overlay);
    overflow: hidden;
    animation: auth-card-in 0.5s var(--ease-out);
}

.auth-form-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-gold);
}

@keyframes auth-card-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .auth-form-card { animation: none; }
}

.auth-form-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: 14px;
    text-align: center;
}

.auth-tabs {
    margin-bottom: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.field-hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: 4px;
}

.auth-forgot {
    text-align: center;
    margin-top: 14px;
    font-size: var(--text-md);
}

.auth-link {
    color: var(--color-gold-text);
    font-weight: 600;
    text-decoration: none;
}

/* ─── Sign-in and sign-up: a light screen (Matan, 4.12) ───────────
   The page was a white card on the dark backdrop, the same look as the landing
   page's hero: "it can't be the same page". Now it is a screen of the app: the
   page's own light background, the logo, a greeting, the fields, and the way
   to the other form at the bottom. The dark backdrop (`.auth-body`) stays for
   the pages that share it: the new password, the wizard, the error page.

   Four states, in `data-view` on `.auth-shell` (`login.js`): login, known (a
   device that signed in before), signup, forgot. */

/* In the app installed on iPhone the clock and battery are drawn in white over
   the page (`black-translucent`). On a light page they would disappear, so the
   strip under them is painted dark. In a browser the strip has no height. */
.auth-light::before, .lp::before {
    content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-sticky);
    height: env(safe-area-inset-top, 0px);
    background: var(--hero-bg);
}

.auth-body.auth-light {
    display: block;
    padding: 0;
    background: var(--color-bg);
    background-image: radial-gradient(90% 100% at 50% 0%, rgba(212, 175, 55, 0.18) 0%, transparent 72%);
    background-size: 100% 420px;
    background-repeat: no-repeat;
}

.auth-shell {
    max-width: 440px;
    margin: 0 auto;
    /* The same fixed height as `.auth-body` and for the same reason: the footer
       is pushed to the bottom of it, and a height that follows the keyboard or
       the password-autofill bar would move the whole page */
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 22px
             calc(20px + env(safe-area-inset-bottom, 0px));
}

.auth-light .auth-back {
    align-self: flex-start;
    margin-bottom: 0;
    color: var(--color-text-muted);
    background: transparent;
    border-color: rgba(var(--ink-rgb), 0.16);
}
.auth-light .auth-back:focus-visible { color: var(--color-text); border-color: var(--color-gold-border); }
@media (hover: hover) and (pointer: fine) { .auth-light .auth-back:hover { color: var(--color-text); border-color: var(--color-gold-border); } }

.auth-main { display: flex; flex-direction: column; transition: opacity 0.18s ease; }

/* Held back until `login.js` knows whether this device is remembered, so the
   full form doesn't flash before "ברוכים השבים". The animation is the way out
   when the script never answers (no JS, a dropped connection): the form shows
   by itself. */
.auth-pending .auth-main { opacity: 0; animation: auth-reveal 0.2s ease 1.2s forwards; }
@keyframes auth-reveal { to { opacity: 1; } }

.auth-head { margin: 26px 0 20px; }

.auth-light .auth-logo-icon {
    width: 64px;
    height: 64px;
    margin: 0;
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg, var(--hero-bg-2) 0%, var(--hero-bg) 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: var(--shadow-lift);
}
.auth-light .auth-logo-icon svg { width: 34px; height: 34px; }

.auth-title {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 24px;
    color: var(--color-text);
}
/* Focused by the script after a move between the forms, for screen readers */
.auth-title:focus { outline: none; }

.auth-sub {
    margin-top: 6px;
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--color-text-muted);
}
.auth-sub[hidden] { display: none; }
.auth-forgot-lede { margin: 0 0 18px; }

/* Who this device remembers, and "החלפה" */
.auth-idchip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    margin-top: 12px;
    padding-block: 3px;
    padding-inline: 16px 6px;
    background: var(--color-card);
    border: 1px solid rgba(var(--ink-rgb), 0.14);
    border-radius: var(--radius-pill);
    font-size: var(--text-md);
    color: var(--color-text-soft);
}
.auth-idchip[hidden] { display: none; }
.auth-idchip bdi { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-idchip .auth-link {
    flex-shrink: 0;
    min-height: 36px;
    padding: 0 10px;
    background: none;
    border: 0;
    border-radius: var(--radius-pill);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.auth-light .auth-link:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; border-radius: var(--radius-xs); }

[data-view="known"] .auth-head { margin-top: 44px; text-align: center; }
[data-view="known"] .auth-logo-icon { width: 84px; height: 84px; margin-inline: auto; border-radius: 50%; }
[data-view="known"] .auth-logo-icon svg { width: 40px; height: 40px; }

.auth-light .form-label { font-size: var(--text-md); }
.auth-light .form-input { min-height: 54px; padding: 14px 16px; border-radius: var(--radius); }
.auth-light .submit-btn { padding: 16px; border-radius: var(--radius); font-size: var(--text-title); }

.auth-light .auth-forgot { margin: -4px 2px 20px; text-align: end; }
[data-view="known"] .auth-forgot, [data-view="forgot"] .auth-forgot { margin: 16px 0 0; text-align: center; }
.auth-light .auth-forgot .auth-link { display: inline-block; padding: 6px 2px; }

/* Off the screen, still in the form: the identifier on a remembered device */
.auth-offscreen {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.auth-foot {
    margin-top: auto;
    padding-top: 28px;
    text-align: center;
    font-size: var(--text-body);
    color: var(--color-text-muted);
}
.auth-switch .auth-link { display: inline-block; padding: 8px 4px; }
[data-view="signup"] .auth-switch-signup,
.auth-shell:not([data-view="signup"]) .auth-switch-login { display: none; }
.auth-light .auth-trust { margin-top: 8px; color: var(--color-text-muted); }

/* A wide screen: the same column, as a card in the middle */
@media (min-width: 720px) {
    .auth-body.auth-light {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 32px 16px;
        background-size: 100% 60vh;
    }
    .auth-shell {
        width: 100%;
        min-height: 0;
        margin: 0;
        padding: 28px 38px 24px;
        background: var(--color-card);
        border: var(--border-subtle);
        border-radius: var(--radius-sheet);
        box-shadow: var(--shadow-lift);
    }
}

/* ─── Onboarding wizard ───────────────────────────────────────── */

.onboarding-container { max-width: 460px; }

.onboarding-card { text-align: right; }

/* A step is hidden by default, and only the first is visible.
   Until now hiding was style="display:none" on every step separately in the
   template, and on step1 it was forgotten, so a new user got the choice screen
   and the family-name question on top of each other, on the very first screen
   they see after signing up. The rule here makes "hidden" the default, so it
   can't be forgotten on a step added in the future.
   The JS keeps managing the transitions with style.display, which beats both. */
.onboarding-step { display: none; }
/* Two opening screens. The page is the same for everyone (the frontend/backend
   split, step 3), so both are in it: step0 shows by default, and whoever joined
   a family that hasn't finished gets stepWaiting instead, switched by
   `onboarding.js` (style.display, like every other step) once
   `/api/screens/onboarding` says so. */
.onboarding-step#step0 { display: block; }

.onboarding-sub {
    font-size: var(--text-md);
    color: var(--color-text-muted);
    margin: -6px 0 16px;
    line-height: 1.5;
}

.onboarding-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.step-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--color-input);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    transition: background 0.25s, color 0.25s;
}

.step-dot.active {
    background: var(--gradient-gold);
    color: #FFFFFF;
}

.step-line {
    width: 24px;
    height: 2px;
    background: var(--color-input);
}

.onboarding-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.onboarding-actions .submit-btn { flex: 2; }
.onboarding-actions .btn-ghost { flex: 1; padding: 14px 0; border-radius: var(--radius-sm); }

.onboarding-pref-list .pref-row {
    border-bottom: 1px solid var(--color-gold-border);
}

.onboarding-pref-list .pref-row:last-child { border-bottom: none; }

.invite-code-card {
    text-align: center;
    margin-bottom: 18px;
}

/* The code is 6 characters and meant to be read out loud: large, spaced, and
   with no word breaking */
.invite-code-card .invite-code-value {
    font-size: var(--text-display);
    font-weight: 700;
    letter-spacing: 0.22em;
    margin: 10px 0 14px;
    word-break: normal;
}

/* ─── The opening fork: a new family or joining ──────────────────────────── */

.onboarding-choice-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.onboarding-choice {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 18px 16px;
    text-align: right;
    background: var(--color-card);
    border: var(--border-gold);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.onboarding-choice:focus-visible {
    background: var(--color-card-hover);
    box-shadow: var(--shadow-lift);
    transform: translateY(-1px);
}
@media (hover: hover) and (pointer: fine) { .onboarding-choice:hover {  background: var(--color-card-hover);  box-shadow: var(--shadow-lift);  transform: translateY(-1px); } }

.onboarding-choice:active { transform: translateY(0); }

.onboarding-choice-icon {
    font-size: var(--text-display);
    line-height: 1;
    flex-shrink: 0;
}

.onboarding-choice-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.onboarding-choice-title {
    font-weight: 600;
    font-size: var(--text-body);
    color: var(--color-text);
}

.onboarding-choice-sub {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    line-height: 1.45;
}

/* The code entry field: left-aligned like the code itself, with spacing that
   makes typing it correctly easier */
.invite-code-input {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-weight: 600;
    text-align: center;
}

.field-hint-ok  { color: var(--color-income); font-weight: 500; }
.field-hint-bad { color: var(--color-expense); font-weight: 500; }

/* ─── Joining a family from settings ─────────────────────────────────────── */

/* The code in settings was hidden and could only be copied; now it is visible,
   because a 6-character code can just be read out over the phone */
.invite-code-inline {
    font-family: monospace;
    font-size: var(--text-base);
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--color-gold-text);
    direction: ltr;
    margin-inline-start: auto;
    margin-inline-end: 10px;
}

.invite-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-row-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.join-family-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.join-family-row .form-input {
    flex: 1;
    min-width: 0;
}

.join-family-row .btn-primary { white-space: nowrap; }

/* "Or" between joining and opening a new family (Matan, 11.10) */
.family-move-or {
    margin: 12px 0 8px;
    text-align: center;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.family-move-new {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.family-move-new .btn-sm { white-space: nowrap; }

.onboarding-type-tabs {
    margin-bottom: 16px;
}

.onboarding-cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

/* Selected: a ✓ in the corner. Not selected: faded, with a dashed border and
   a struck-through name, so there is no doubt what will go in (Matan, 31.10:
   two people deselected everything instead of choosing) */
.onboarding-cat-btn {
    position: relative;
    opacity: 0.45;
    filter: grayscale(0.7);
    border-style: dashed;
}
.onboarding-cat-btn:not(.active) > span:last-child { text-decoration: line-through; }

.onboarding-cat-btn.active {
    opacity: 1;
    filter: none;
    border-style: solid;
}
.onboarding-cat-btn.active::after {
    content: "✓";
    position: absolute; top: 4px; inset-inline-start: 5px;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-gold); color: #FFFFFF;
    font-size: var(--text-2xs); font-weight: 700; line-height: 1;
}
.onboarding-cat-count { margin: 0 0 8px; font-size: var(--text-sm); color: var(--color-text-muted); }
.onboarding-cat-count.is-empty { color: var(--color-expense); font-weight: 600; }

.onboarding-add-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.onboarding-add-row .onboarding-new-name { flex: 1; min-width: 0; }
.onboarding-add-row .btn-primary { padding: 0 16px; white-space: nowrap; }

/* Alerts */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    font-weight: 500;
    margin-bottom: 16px;
}

.alert-success {
    background: rgba(21, 128, 61, 0.08);
    border: 1px solid rgba(21, 128, 61, 0.25);
    color: var(--color-income);
}

.alert-error {
    background: rgba(185, 28, 28, 0.07);
    border: 1px solid rgba(185, 28, 28, 0.25);
    color: var(--color-expense);
}

/* ─── Larger screens ──────────────────────────────────────────── */

@media (min-width: 600px) {
    .page-hero { padding-top: 32px; }
    .hero-amount { font-size: 4rem; }
    .category-grid, .onboarding-cat-grid { grid-template-columns: repeat(5, 1fr); }
    .kpi-chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* The iOS haptic switch: must stay rendered (display:none cancels the effect),
   but invisible. The values match what was tested on a real device: don't
   change them without checking again that the tap still arrives. */
.haptic-switch {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ─── Reduced motion ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        /* Without this an endless animation (the scan line, the spinner) keeps
           running at 0.01ms a cycle: a flicker, not a stop */
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .anim-rise { opacity: 1; }
    /* The 0.01ms above also applies to `visibility`, of the sheet and of everything
       inside it (`visibility` is inherited, and every descendant "delays" by
       itself). On the focus frame the amount field is still `hidden`, and the
       caret stays on +. Found 12.10. */
    .modal-overlay.open, .modal-overlay.open * { transition: none !important; }
}

/* ═══ Family settings (the settings page + an onboarding step) ═══ */

/* pref-list/pref-row/pref-label/pref-note: used by the onboarding wizard only
   (the settings page uses the general group-row, to match the other groups) */
.pref-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pref-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
}

.pref-label {
    font-size: var(--text-body);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pref-note {
    font-size: var(--text-2xs);
    color: var(--color-text-muted, #78716C);
}

.group-row.disabled .group-row-label,
.group-row.disabled .group-row-hint { opacity: 0.45; }

/* on/off switch */
.pref-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.pref-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pref-slider {
    position: absolute;
    inset: 0;
    background: var(--toggle-off);
    border-radius: var(--radius-sheet);
    cursor: pointer;
    transition: background 0.2s ease;
}

.pref-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 3px;
    right: 3px;
    background: #FFFFFF;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

.pref-switch input:checked + .pref-slider { background: var(--color-gold); }
/* Off is hollow, on is filled (audit, 22.11): a grey-brown track next to a gold
   one read as "on" at a glance. The outline keeps the 3:1 edge contrast. */
.pref-switch input:not(:checked) + .pref-slider { background: transparent; box-shadow: inset 0 0 0 2px var(--toggle-off); }
.pref-switch input:not(:checked) + .pref-slider::before { background: var(--toggle-off); box-shadow: none; }
.pref-switch input:checked + .pref-slider::before { transform: translateX(-20px); }
.pref-switch input:disabled + .pref-slider { opacity: 0.4; cursor: not-allowed; }
.pref-switch input:focus-visible + .pref-slider { outline: 2px solid var(--color-gold-bright); outline-offset: 2px; }
/* The bright gold ring is 2.1:1 on a white card: the darker gold there (5.6) */
:root:not([data-theme="dark"]) .pref-switch input:focus-visible + .pref-slider { outline-color: var(--color-gold-text); }

/* A temporary "recent transaction" row (optimistic UI), until the full refresh
   replaces it with real data */
.tx-pending {
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
}

/* ── Swipe actions on transaction rows: right=edit, left=delete (in addition
   to a tap) ── */
.swipe-content {
    position: relative;
    z-index: 2;
    transition: transform 0.2s ease-out;
    touch-action: pan-y;
    background: inherit;
}

.swipe-action {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-2xs);
    font-weight: 700;
    white-space: nowrap;
    color: #FFFFFF;
    z-index: 1;
    gap: 4px;
}

.swipe-action svg { width: 14px; height: 14px; flex-shrink: 0; }

.swipe-action-edit {
    left: 0;
    background: var(--gradient-gold);
}

.swipe-action-delete {
    right: 0;
    background: var(--gradient-danger);
}

li.transaction-item.swipe-ready .swipe-action-edit  { border-radius: var(--radius) 0 0 var(--radius); }
li.transaction-item.swipe-ready .swipe-action-delete { border-radius: 0 var(--radius) var(--radius) 0; }

li.transaction-item.swipe-ready {
    display: block;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: hidden;
    position: relative;
}

li.transaction-item.swipe-ready > .swipe-content {
    /* block, not flex: the white card holds a header + an editor one under the
       other. The row's horizontal layout moved to .tx-head. */
    display: block;
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow-card);
    width: 100%;
    box-sizing: border-box;
}

.cat-tx-row.swipe-ready {
    /* flex, and stretched: the row is at least 44px tall (see "at least 44px"
       below) and its content 35px. As a block the content kept its own height,
       and under it the edit and delete panels showed: a gold strip and a red
       one beneath every row a finger had touched (Matan, 28.11: "something is
       stuck here"). Stretched, the content covers the whole row. */
    display: flex;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    position: relative;
    /* Square, row and content both: clipping the panels to rounded corners
       left a thin red and gold arc at each corner of a touched row, where the
       edge of the clip is blended. With nothing rounded, the content covers
       the panels to the last pixel. */
    border-radius: 0;
}

.cat-tx-row.swipe-ready > .swipe-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 0;       /* see the row, above */
    /* An opaque background that hides the action panels until swiped, matching
       the beige background of .cat-tx-list (drilldown on the month page). In a
       standalone list on a project page the background is white; see the
       override below. */
    background: var(--color-input);
}

.cat-tx-list-standalone .cat-tx-row.swipe-ready > .swipe-content {
    background: var(--color-card);
}

.recurring-row.swipe-ready {
    display: block;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.recurring-row.swipe-ready > .swipe-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    width: 100%;
    box-sizing: border-box;
    /* opaque background: recurring transaction rows sit on a white card in settings */
    background: var(--color-card);
}

/* Soft loading feedback while the modal's data loads (the FAB or a tapped
   transaction row) */
.is-loading-trigger {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity var(--dur-quick);
}

/* Enlarging the actual tap area to 44×44 without changing the visual size: a
   transparent, centred pseudo-element, larger than the visible icon */
.modal-close::before,
.edit-cat-btn::before,
.delete-cat-btn::before,
.receipt-badge::before,
.stats-nav-btn::before,
.pref-switch::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
}

/* And wide, low buttons (Matan, 5.10): 44 in height only. In width only half
   the gap between neighbours (6px between the range buttons), so two areas
   don't overlap */
.range-chip::before,
.back-to-current::before {
    content: '';
    position: absolute;
    top: 50%;
    height: 44px;
    left: -3px;
    right: -3px;
    transform: translateY(-50%);
}

/* ═══ Legal pages ══════════════════════════════════════════════════════════ */

.legal-body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    margin: 0;
}

.legal-page {
    max-width: 680px;
    margin: 0 auto;
    /* "← back" sat at the clock's height on iPhone; see `.auth-body` */
    padding: calc(26px + env(safe-area-inset-top, 0px)) 20px
             calc(60px + env(safe-area-inset-bottom, 0px));
}

.legal-back {
    display: inline-block;
    color: var(--color-gold-text);
    text-decoration: none;
    font-size: var(--text-body);
    margin-bottom: 20px;
}

.legal-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 5.5vw, 2.1rem);
    font-weight: 700;
    margin: 0 0 6px;
}

.legal-updated {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin: 0 0 26px;
}

.legal-lead {
    font-size: var(--text-base);
    line-height: 1.72;
    color: var(--color-text-soft);
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin: 0 0 8px;
}

.legal-h2 {
    font-size: var(--text-title);
    font-weight: 700;
    margin: 32px 0 10px;
    padding-bottom: 8px;
    border-bottom: var(--border-subtle);
}

.legal-p, .legal-list {
    font-size: var(--text-body);
    line-height: 1.75;
    color: var(--color-text-soft);
}

.legal-list { padding-inline-start: 22px; }
.legal-list li { margin-bottom: 9px; }

.legal-p a, .legal-list a { color: var(--color-gold-text); }

.legal-footer-links {
    margin-top: 40px;
    padding-top: 18px;
    border-top: var(--border-subtle);
    font-size: var(--text-md);
    text-align: center;
}

.legal-footer-links a { color: var(--color-gold-text); text-decoration: none; }

/* A back link from the auth screens to the landing page. Until it was added,
   whoever tapped "open an account" entered a one-way path and had to use the
   browser's back button. */
.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 18px;
    padding: 8px 15px 8px 13px;
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--hero-text-muted);
    text-decoration: none;
    background: var(--hero-chip-bg);
    border: 1px solid var(--hero-chip-border);
    border-radius: var(--radius-pill);
    transition: color 0.15s ease, border-color 0.15s ease;
}

.auth-back svg { width: 15px; height: 15px; flex-shrink: 0; }

.auth-back:focus-visible {
    color: var(--hero-text);
    border-color: rgba(212, 175, 55, 0.45);
}
@media (hover: hover) and (pointer: fine) { .auth-back:hover {  color: var(--hero-text);  border-color: rgba(212, 175, 55, 0.45); } }

.auth-back:focus-visible {
    outline: 2px solid var(--color-gold-bright);
    outline-offset: 2px;
}

/* ═══ Landing page ═════════════════════════════════════════════════════════
   SmartFin's essence is a shared family budget, not receipt scanning. So the
   page's hero is the month screen itself, with a "who spent" card floating on
   it: one screen several people enter into. Receipt scanning moved down to the
   entry section, as one of three ways.
   The typography is identical to the app (Rubik through --font-display): the
   landing page is the first impression, and if it looks like another product,
   that is exactly what it signals.
   ────────────────────────────────────────────────────────────────────────── */

.lp {
    --lp-paper: #FFFCF2;
    --lp-ink:   #2A2317;
    --lp-rule:  rgba(42, 35, 23, 0.14);
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    margin: 0;
    overflow-x: hidden;
}

.lp h1, .lp h2, .lp h3 { font-family: var(--font-display); }

/* ── Hero: the first screen ────────────────────────────────────────────────
   A welcome that fits one phone screen (Matan, 4.12): the brand, the product
   itself slightly tilted with two things floating on it, one sentence, and the
   two ways in at the bottom. Light: the dark hero looked like the sign-in page.
   The strip under the iPhone's clock is painted with `.auth-light::before`. */

.lp-hero {
    /* The glow starts under the top edge, not at it: the phone's status bar is
       painted in the page's colour, and a glow that began at the edge left it
       looking like a pale strip above the page (Matan, 5.12, on an iPhone) */
    background:
        linear-gradient(to bottom, var(--color-bg), transparent 96px),
        radial-gradient(90% 50% at 50% 0%, rgba(212, 175, 55, 0.2) 0%, transparent 70%);
    color: var(--color-text);
    /* The brand row sat under the clock in the installed app and couldn't be
       read; the spacing was missing here and existed on every other page */
    padding: calc(16px + env(safe-area-inset-top, 0px)) 22px
             calc(22px + env(safe-area-inset-bottom, 0px));
    /* `svh`, not `dvh`: the screen's smallest height, so the buttons at the
       bottom are in view from the first moment and nothing moves when the
       browser's bar hides */
    min-height: 100vh;
    min-height: 100svh;
    display: flex; flex-direction: column;
}

.lp-nav {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; max-width: 1080px; margin: 0 auto;
}

.lp-brand {
    display: inline-flex; align-items: center; gap: 9px;
    font-family: var(--font-body); font-weight: 700; font-size: var(--text-title);
}
.lp-brand svg {
    width: 34px; height: 34px; padding: 7px; border-radius: 10px;
    background: var(--hero-bg); color: var(--color-gold-bright);
}

/* On a phone the way in for a returning visitor is the second button at the
   bottom; the link at the top is for wide screens, where the buttons are small */
.lp-nav-link {
    display: none;
    color: var(--color-text-soft); text-decoration: none; font-size: var(--text-body); font-weight: 500;
    padding: 9px 16px; border-radius: var(--radius-pill);
    border: 1px solid rgba(var(--ink-rgb), 0.14); background: var(--color-card);
    transition: color 0.15s ease, border-color 0.15s ease;
}
@media (hover: hover) and (pointer: fine) { .lp-nav-link:hover { color: var(--color-text); border-color: var(--color-gold-border); } }

.lp-hero-grid {
    flex: 1; min-height: 0;
    width: 100%; max-width: 1080px; margin: 0 auto;
    display: flex; flex-direction: column;
}

.lp-hero-copy { text-align: center; }

.lp-eyebrow {
    /* 0.16em broke "ניהול תקציב משפחתי" into single letters (Matan, 7.10) */
    font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em;
    color: var(--color-gold-text); margin: 0 0 16px;
    display: none; align-items: center; gap: 10px;
}
.lp-eyebrow::after {
    content: ""; flex: 1; height: 1px; max-width: 92px;
    background: linear-gradient(to left, rgba(166, 124, 0, 0.55), transparent);
}

.lp-h1 {
    font-size: clamp(1.85rem, 8.2vw, 2.15rem);
    font-weight: 700; line-height: 1.18; margin: 0 0 10px;
}
.lp-h1 em { font-style: normal; color: var(--color-gold-text); }

.lp-lede {
    font-size: var(--text-base); line-height: 1.55;
    color: var(--color-text-muted); margin: 0 auto 20px; max-width: 30ch;
    text-wrap: balance;
}

.lp-actions { display: flex; flex-direction: column; gap: 10px; }

.lp-btn {
    display: inline-block; background: var(--gradient-gold); color: #fff;
    text-decoration: none; font-weight: 700; font-size: 1rem;
    padding: 15px 34px; border-radius: var(--radius-pill); box-shadow: var(--shadow-gold);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
@media (hover: hover) and (pointer: fine) { .lp-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(166,124,0,0.38); } }

.lp-btn-quiet {
    display: inline-block; color: var(--color-text); text-decoration: none;
    font-weight: 600; font-size: 1rem; padding: 15px 26px; border-radius: var(--radius-pill);
    border: 1px solid rgba(var(--ink-rgb), 0.14); background: var(--color-card);
}
@media (hover: hover) and (pointer: fine) { .lp-btn-quiet:hover { border-color: var(--color-gold-border); } }

/* The two ways in, on a phone: full width, one under the other, in the thumb's reach */
.lp-actions .lp-btn, .lp-actions .lp-btn-quiet {
    display: block; text-align: center; padding: 16px; border-radius: var(--radius); font-size: var(--text-title);
}

/* ── The signature: the real month screen, in a phone ─────────────────────── */

/* The picture takes the height that is left after the words and the buttons,
   and the phone is cut where that height ends: a tall phone shows the whole
   chart, a short one (iPhone SE) the balance and the top of the chart, and on
   both the two buttons are in view without scrolling. */
.lp-showcase {
    flex: 1 1 0; min-height: 200px;
    display: flex; justify-content: center; align-items: flex-start;
    overflow: hidden;
    padding-top: 12px; margin-bottom: 16px;
    -webkit-mask-image: linear-gradient(#000 calc(100% - 64px), transparent);
    mask-image: linear-gradient(#000 calc(100% - 64px), transparent);
}

/* --shot-w is the width of the screen inside the frame; the month's name over
   the picture is sized and placed from it */
.lp-phone {
    --shot-w: min(264px, 68vw);
    flex-shrink: 0;
    width: calc(var(--shot-w) + 16px); padding: 8px 8px 0;
    border-radius: 40px 40px 0 0;
    background: var(--hero-bg);
    box-shadow: 0 18px 44px rgba(31, 24, 8, 0.22);
}
.lp-shot { position: relative; border-radius: 32px 32px 0 0; overflow: hidden; }
.lp-shot img { display: block; width: 100%; height: auto; }
/* Dark mode: the dark screen, and a line around the frame, which is otherwise
   the same black as the page */
.lp-shot-dark { display: none !important; }
[data-theme="dark"] .lp-shot-dark { display: block !important; }
[data-theme="dark"] .lp-shot-light { display: none; }
[data-theme="dark"] .lp-phone { box-shadow: 0 0 0 1px rgba(255, 248, 231, 0.14), 0 18px 44px rgba(0, 0, 0, 0.5); }
/* Where the screen's own title sits: 28px down and 20px in on a 390px screen,
   24px/36px bold (the numbers `landing_shot.cjs` prints) */
.lp-shot-month {
    position: absolute;
    top: calc(var(--shot-w) * 28 / 390); inset-inline-start: calc(var(--shot-w) * 20 / 390);
    font-family: var(--font-body); font-weight: 700; color: var(--hero-text);
    font-size: calc(var(--shot-w) * 24 / 390); line-height: 1.5;
    white-space: nowrap;
}

/* ── The two documents, under the buttons ─────────────────────────────────── */

.lp-legal { display: flex; justify-content: center; gap: 20px; margin-top: 14px; font-size: var(--text-sm); }
.lp-legal a { color: var(--color-text-muted); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .lp-legal a:hover { color: var(--color-gold-text); } }

.lp a:focus-visible, .lp-nav-link:focus-visible {
    outline: 2px solid var(--color-gold-bright); outline-offset: 3px; border-radius: 6px;
}

@media (min-width: 860px) {
    /* Two columns: the words and the buttons beside the screen, in the middle
       of the window's height. The page is this one screen. */
    .lp-hero { padding-top: 20px; padding-bottom: 40px; }
    .lp-nav-link { display: inline-block; }
    .lp-hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 48px; align-items: center; align-content: center; }
    .lp-hero-copy { order: -1; text-align: start; }
    .lp-eyebrow { display: flex; }
    .lp-h1 { font-size: clamp(2.6rem, 4.4vw, 3.5rem); line-height: 1.14; margin-bottom: 20px; }
    .lp-lede { font-size: var(--text-title); line-height: 1.68; margin: 0 0 32px; max-width: 40ch; }
    .lp-actions { flex-direction: row; flex-wrap: wrap; gap: 12px; }
    .lp-actions .lp-btn { display: inline-block; padding: 15px 34px; border-radius: var(--radius-pill); font-size: 1rem; }
    .lp-actions .lp-btn-quiet { display: inline-block; padding: 15px 26px; border-radius: var(--radius-pill); font-size: 1rem; }
    /* Beside the words the phone has a height of its own */
    .lp-showcase { flex: none; height: 540px; margin-bottom: 0; }
    .lp-phone { --shot-w: 284px; }
    .lp-legal { justify-content: flex-start; margin-top: 26px; }
}

/* ─── Contact at the bottom of settings ──────────────────────────────────
   Outside every accordion and always visible: it is the only support channel,
   and the privacy policy promises it will be reachable in the app. */
.settings-contact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    /* The spacing from the bottom bar (including the iPhone home area) is already
   at the bottom of `main` */
    padding: 12px 16px 0;
    text-align: center;
}
.settings-contact-label { margin: 0; font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.6; }
.settings-contact-link {
    display: inline-block;
    padding: 6px 2px;                       /* a reasonable touch target inside a line of text */
    color: var(--color-gold-text);
    font-weight: 700;
    text-decoration: none;
}

/* ─── Project management: one continuous menu ────────────────────────────
   The page was four separate `chart-card`s with 16px between them, and the
   last in a completely different style: one settings screen that looked like
   four pasted together. One container, and the division is done with a line. */
.project-settings {
    background: var(--color-card);
    border: var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: 16px;
}
.project-settings-block { padding: 14px 16px; }
.project-settings .form-group { margin-bottom: 12px; }

/* The tracked departments on one row, not three rows (Matan, 9.10: the page
   was too long) */
.track-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }

/* The save bar (Matan, 9.10): stays at the bottom of the screen above the bar,
   for the whole page and not just the first part. When the keyboard is open the
   bar disappears (see "keyboard open"), and the save bar drops into its place so
   it doesn't float in the middle. */
.project-save-bar {
    position: sticky;
    bottom: calc(var(--dock-height) + var(--dock-gap) * 2 + env(safe-area-inset-bottom, 0px));
    z-index: 5;
    display: flex; gap: 8px;
    padding: 10px;
    background: var(--dock-bg);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(var(--ink-rgb), 0.08);
    border-radius: var(--radius);
    box-shadow: var(--shadow-dock);
}
.project-save-btn, .project-save-cancel {
    padding: 12px 18px; border-radius: var(--radius-sm); font-size: var(--text-body); font-weight: 600;
    text-align: center; text-decoration: none;
}
.project-save-btn { flex: 1; }
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
    .project-save-bar { background: var(--dock-bg-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Finishing and deleting at the bottom of the project page (Matan, 9.10) */
.project-finish .group-row { padding: 4px 0; }
.project-finish > .group-divider { margin: 10px 0; }

/* The project's categories: a collapsible heading (Matan, 9.10). The whole row
   is tappable, not just the arrow */
.settings-collapse-title { margin: 0; }
.settings-collapse {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: none; border: 0; padding: 4px 0; margin: 0;
    font: inherit; color: inherit; text-align: start; cursor: pointer;
}
.settings-collapse-count { color: var(--color-text-muted); font-weight: 500; font-size: var(--text-body); }
.settings-collapse .expand-chevron { margin-inline-start: auto; transition: transform 0.2s; }
.settings-collapse[aria-expanded="true"] .expand-chevron { transform: rotate(180deg); }

/* Changes not saved yet: marked on screen until "save changes" */
.cat-pending-tag {
    display: inline-block; margin-inline-start: 8px;
    font-size: var(--text-2xs); font-weight: 600; color: var(--color-gold-text);
}
.category-row.is-deleted .cat-row-icon,
.category-row.is-deleted .cat-row-name { opacity: 0.55; }
.category-row.is-deleted .cat-name-text { text-decoration: line-through; }
.category-row.is-deleted .cat-pending-tag { display: block; margin: 2px 0 0; color: var(--color-expense); }
.pending-note { margin: 4px 0 0; font-size: var(--text-sm); font-weight: 600; color: var(--color-gold-text); }
.project-save-error:empty { display: none; }
.project-save-error { margin: 0 0 8px; text-align: center; }

/* the first heading already carries the block's spacing */
.project-settings-block > .chart-title:first-child { margin-top: 0; }

/* The dividing lines stretch to the full width; otherwise they look like a
   line inside a paragraph and not a border between two parts. */
.project-settings > .group-divider { margin: 0; }

/* ─── The delete area inside the project ─────────────────────────────── */
.project-danger .group-row-label { color: var(--color-expense); }

/* ─── The dashboard bar: expenses and savings separately ─────────────────
   Before, this was one bar that added both together and called the total
   "used": a month with 20% expenses and 69% savings showed as an almost full
   bar. Money saved wasn't used. */
/* The first version coloured both parts the same gold, one of them faded, and
   at 8 pixels tall it looked exactly like the old bar. A change you can't see
   isn't a change. The colours here come from the language already used
   throughout the app: expenses in red, savings in gold. */
.balance-bar-split {
    display: flex;
    gap: 3px;
    height: 10px;   /* 8 was too thin to show a split */
}
.balance-bar-split .balance-bar-fill {
    flex: 0 0 auto;
    border-radius: var(--radius-pill);
    min-width: 0;
}
/* The empty track behind isn't decoration: it is what you haven't spent or saved yet. */

.balance-bar-fill.spent { background: var(--color-expense); }
.balance-bar-fill.saved { background: var(--color-savings); }

/* The overage red must beat the expense part's usual colour, so it is defined
   here, after it, and with the same specificity inside the hero. */
.balance-bar-fill.spent.danger { background: var(--gradient-danger); }

/* A colour key next to each number in the legend; otherwise there is no way to
   tell which part is which */
.balance-bar-legend .bar-key {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-inline-end: 5px;
    vertical-align: baseline;
}
.balance-bar-legend .bar-key.spent { background: var(--color-expense); }
.balance-bar-legend .bar-key.saved { background: var(--color-savings); }

/* In the dark hero the light versions are needed; otherwise both blend into
   the background */
.page-hero .balance-bar-fill.spent { background: var(--color-expense-light); }
.page-hero .balance-bar-fill.spent.danger { background: var(--gradient-danger); }
.page-hero .balance-bar-fill.saved { background: var(--color-savings-light); }
.page-hero .balance-bar-legend .bar-key.spent { background: var(--color-expense-light); }
.page-hero .balance-bar-legend .bar-key.saved { background: var(--color-savings-light); }
.page-hero .balance-bar-legend { color: var(--hero-text-muted); }

/* ─── The project settings page: room to breathe ─────────────────────────── */

/* The floating + is "add a transaction". On a settings screen it has nothing to
   do, and it sat in the bottom-left corner, exactly on "delete project". The
   irreversible action on the page was half hidden behind a button that didn't
   belong there. */
body.no-fab .fab { display: none; }
/* A screen that is one task (creating a project, Matan 23.11): no bottom menu,
   and its own bar of actions sits where the menu was */
body.no-nav .bottom-nav { display: none; }
body.no-nav .project-save-bar { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
body.no-nav .install-bar { display: none; }     /* it would sit on the bar of actions */
body.no-fab .bottom-nav { left: var(--dock-side); }    /* no +: the bar at full width */
/* Settings have no + button, so no room is needed for it at the bottom (Matan,
   11.10). The +'s 96 pixels made settings taller than the screen even with
   everything closed: after scrolling to the bottom the spring stopped there, and
   the "settings" heading stayed off screen. Spacing from the bar only.
   (Project editing: also without +, but with a save bar at the bottom.) */
body.settings-page .main-content {
    padding-bottom: calc(var(--dock-height) + var(--dock-gap) + env(safe-area-inset-bottom, 0px) + 16px);
}
/* Sign out and "write to us" at the bottom of the screen (Matan, 13.10): the
   page fills at least the screen's height, and the bottom is pushed down. When a
   box is open and the page is long, simply at the end, as usual.
   The minimum height stays that of `body` (`100lvh + 1px`): `100dvh` here brought
   back the bug of 30.9: on a page no taller than the screen the bottom menu
   rises (Matan, 13.10). */
body.settings-page { display: flex; flex-direction: column; }
body.settings-page > .main-content { flex: 1 0 auto; display: flex; flex-direction: column; width: 100%; }
body.settings-page .settings-groups { flex: 1 0 auto; }
.settings-footer { margin-top: auto; padding-top: 16px; }
/* The page that loads its own data (`settings_view.html`) holds the groups in
   two more boxes: they pass the height down, so the bottom is pushed down the
   same way. `hidden` still wins while the data is on its way. */
body.settings-page #settingsView, body.settings-page #settingsBody { flex: 1 0 auto; display: flex; flex-direction: column; }

/* `.category-row:last-child` resets the bottom padding, and right after it the
   add row started, so "add" looked like a button of the last category and not
   a separate form. A line and a little air separate "what exists" from "add new". */
#projectCategoriesArea .add-cat-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: var(--border-subtle);
}

/* the delete row was stuck to the bottom of the card. */
.project-settings-block.project-danger { padding-bottom: 22px; }

/* The "expenses / income / savings" tabs touched the first row under them.
   `.type-toggle` has no `margin-bottom`, and `.category-row:first-child` resets
   the top padding: two decisions reasonable on their own that meet at zero
   spacing, so the active button and the first category row look like one
   component. Also present in category management in settings, not only in a
   project. */
.project-cat-tabs,
.cat-type-tabs { margin-bottom: 10px; }

/* The id selector is needed to beat `.category-row:first-child`, which resets it. */
#projectCategoriesArea .category-row:first-child,
#categoriesArea .category-row:first-child { padding-top: 10px; }

/* No bar on this screen (`no-nav`): no fade either. It covered the screen's own
   bar of actions, which sits where the menu was. */
body.no-nav:has(> .bottom-nav)::after { content: none; }

/* Pull down to refresh in the installed app (Matan, 30.9, idea 14; like on
   iPhone, 13.10): the dark band revealed above the page as it comes down, and
   iOS's loading spinner inside it */
.ptr-layer {
    position: fixed; top: 0; left: 0; right: 0; height: 0;
    z-index: 0; overflow: hidden; pointer-events: none;
    background: var(--hero-bg-2);
}
.ptr-spinner {
    position: absolute; left: 50%; width: 24px; height: 24px; margin-left: -12px;
    color: rgba(255, 248, 231, 0.75); opacity: 0;
}
.ptr-layer.spinning .ptr-spinner { animation: ptr-spin .8s steps(8) infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ptr-layer.spinning .ptr-spinner { animation-duration: 2.4s; } }
body.ptr-active > .page-hero, body.ptr-active > .main-content {
    transform: translateY(var(--ptr-y, 0px)); transition: var(--ptr-t, none);
}

/* by category on the comparison page (Matan, 30.9) */
/* Columns by content: "החודש הכי יקר - ספטמבר" is longer than its neighbours
   (Matan, 1.10). The label on one line and the amount under it, centred on the
   middle of the label. On a narrow screen where the label wraps anyway, the
   amounts stay on one line below. */
.cat-trend-stats {
    display: grid; grid-template-columns: auto auto auto; justify-content: space-between; gap: 8px;
    margin: 4px 0 10px; font-size: var(--text-xs); color: var(--color-text-muted);
}
.cat-trend-stats > div { display: flex; flex-direction: column; align-items: center; text-align: center; }
.cat-trend-stats b {
    display: block; margin-top: auto; padding-top: 2px; font-size: 1rem; color: var(--color-text);
    font-variant-numeric: tabular-nums;
}
.cat-trend-stats .num { direction: ltr; unicode-bidi: isolate; }
.cat-trend-stats .nowrap { white-space: nowrap; }   /* "- ספטמבר" doesn't break after the dash */
.line-chart-wrap.cat-trend-wrap { height: 200px; margin-inline: -10px; }

/* The search-all-months screen (Matan, 30.9, round 6, item 2). Above the page
   and below the edit sheet (z-index 100), so tapping a result opens it above. */
.search-screen {
    position: fixed; inset: 0; z-index: 95;
    background: var(--color-bg);
    display: flex; flex-direction: column;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
}
.search-screen[hidden] { display: none; }
body.search-open { overflow: hidden; }
.search-bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--color-card); border: var(--border-subtle);
    border-radius: var(--radius); padding: 4px 6px 4px 12px; box-shadow: var(--shadow-card);
}
.search-bar-icon { width: 20px; height: 20px; color: var(--color-text-muted); flex: none; }
.search-input {
    flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
    font: inherit; font-size: 1rem; padding: 10px 0; color: var(--color-text);
}
.search-close {
    width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none;
    background: var(--color-input); color: var(--color-text-soft); font-size: 1rem;
}
/* Search filters (Matan, 22.11) */
.search-filter-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.search-filter-toggle { min-height: 36px; }
.search-filter-clear { border: 0; background: transparent; font: inherit; font-size: var(--text-md); font-weight: 600; color: var(--color-gold-text); min-height: 36px; padding-inline: 6px; cursor: pointer; }
.search-filter-clear[hidden], .search-filters[hidden], .search-filter-row[hidden] { display: none; }
.search-filters { margin-top: 8px; padding: 12px 14px; border-radius: var(--radius); background: var(--color-card); border: var(--border-subtle); display: flex; flex-direction: column; gap: 10px; }
.search-filter-row { display: flex; align-items: center; gap: 10px; }
.search-filter-label { flex: 0 0 44px; font-size: var(--text-md); font-weight: 600; color: var(--color-text-soft); }
.search-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.search-chips .date-chip { min-height: 36px; padding-inline: 12px; }
.search-amounts { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--text-md); color: var(--color-text-muted); }
.search-amounts .form-input { width: 104px; min-width: 0; padding-block: 8px; font-size: max(1rem, 16px); }
.search-summary { margin: 12px 4px 4px; font-size: var(--text-md); color: var(--color-text-muted); }
.search-results {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;   /* At the end of the list scrolling stops, it doesn't continue to the page
   (touch round) */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.search-month { margin: 16px 4px 6px; font-size: var(--text-md); font-weight: 700; color: var(--color-text-soft); }
.search-list { display: block; background: var(--color-card); border-radius: var(--radius); padding: 2px 12px; }
/* The browser's ✕ in a search field: we have our own close button next to it */
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

/* A finished project (Matan, 30.9, round 6, item 3) */
.project-archived-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    /* A solid background: the bar sits on the edge of the dark hero, and a
       transparent background was unreadable there */
    background: var(--color-card); border: 1px solid var(--color-gold-border);
    box-shadow: var(--shadow-card);
    color: var(--color-gold-text); font-weight: 600; font-size: var(--text-body);
    border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
}

/* Dragging categories to reorder (Matan, 30.9, round 6, item 5). `touch-action:
   none` on the handle only: there dragging moves the row, and anywhere else it
   scrolls the page */
.cat-drag-handle {
    flex: none; width: 28px; height: 36px;
    display: grid; place-items: center;
    color: var(--color-text-muted); cursor: grab;
    touch-action: none; user-select: none; -webkit-user-select: none;
}
.cat-drag-handle svg { width: 18px; height: 18px; }
.category-row.dragging {
    position: relative; z-index: 5;
    background: var(--color-card);
    box-shadow: var(--shadow-lift);
    border-radius: var(--radius-sm);
}
.category-row.dragging .cat-drag-handle { cursor: grabbing; color: var(--color-gold-text); }

/* Picking an icon from a grid (Matan, 30.9, round 6, item 8). Above the
   transaction sheet (100) and below the confirm (200). */
.icon-picker {
    position: fixed; inset: 0; z-index: 180;
    background: rgba(12, 9, 4, 0.45);
    display: flex; align-items: flex-end; justify-content: center;
}
.icon-picker[hidden] { display: none; }
.icon-picker-card {
    width: 100%; max-width: 560px; max-height: 80vh; max-height: 80dvh; overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--color-card); border-radius: 20px 20px 0 0;
    padding: 16px 14px calc(env(safe-area-inset-bottom, 0px) + 16px);
    box-shadow: var(--shadow-lift);
}
.icon-picker-title { margin: 0 0 10px; font-weight: 700; font-size: 1rem; }
.icon-picker-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.icon-picker-label { flex: none; width: 4.2em; font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 600; }
.icon-picker-grid { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; }
.icon-picker-btn {
    aspect-ratio: 1; min-height: 36px; border: 0; border-radius: var(--radius-sm);
    background: transparent; font-size: var(--text-xl); line-height: 1; cursor: pointer;
}
.icon-picker-btn:focus-visible { background: var(--color-input); }
@media (hover: hover) and (pointer: fine) { .icon-picker-btn:hover { background: var(--color-input); } }
.icon-picker-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
input.emoji-input { cursor: pointer; caret-color: transparent; }
input.emoji-input[data-free-typing] { cursor: text; caret-color: auto; }

/* The header that stays at the top of the month page (Matan, 30.9, round 6,
   item 12). In the hero's colours, below the clock and battery area, below the
   transaction sheet (100). */
.month-sticky {
    position: fixed; top: 0; left: 0; right: 0; z-index: 60;
    background: linear-gradient(170deg, var(--hero-bg), var(--hero-bg-2));
    color: var(--hero-text);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.month-sticky-top {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 18px 8px;
    background: transparent; color: inherit; border: 0; font: inherit; text-align: start; cursor: pointer;
}
/* Shortcuts to the page's sections (Matan, 22.11). All of them in one row, in
   equal columns, with nothing to scroll sideways (Matan: "in one screen"); the
   label shrinks to fit a narrow phone or extra-large text. 36px chips with a
   44px tap height. */
.month-sticky-nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 5px; padding: 0 12px 10px; }
.month-sticky-nav[hidden] { display: none; }
.month-jump {
    position: relative; min-width: 0; min-height: 36px; padding: 0 2px; border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.06);
    color: var(--hero-text); font: inherit; font-size: clamp(12px, 3.6vw, 14px); font-weight: 600; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.month-jump::before { content: ""; position: absolute; inset: -4px 0; }
.month-jump.is-current { background: var(--color-gold); border-color: var(--color-gold); color: #FFFFFF; }
.month-sticky[hidden] { display: none; }
.month-sticky-title { font-weight: 700; font-size: 1rem; }
.month-sticky-value { font-weight: 700; font-size: var(--text-body); font-variant-numeric: tabular-nums; direction: rtl; }
.month-sticky-value.surplus { color: var(--color-income-light); }
.month-sticky-value.deficit { color: var(--color-expense-light); }

/* Picking a colour for a family member (Matan, 30.9, round 6, item 13): a
   button on my row, and a bottom sheet with the name tag in every colour */
.member-color-open {
    display: inline-flex; align-items: center; gap: 8px; margin-top: 8px;
    padding: 6px 12px; min-height: 36px; border-radius: var(--radius-pill);
    background: var(--color-input); border: var(--border-subtle);
    color: var(--color-text-soft); font: inherit; font-size: var(--text-sm); font-weight: 600; cursor: pointer;
}
.member-color-swatch { width: 16px; height: 16px; border-radius: 50%; flex: none; }
/* "My colour": an ordinary row in "my details" (Matan, 11.10), without the top spacing */
.group-row .member-color-open { margin-top: 0; flex: none; }
/* The "family members" heading above the list in "the family" */
.members-title { margin-bottom: 4px; }
.color-sheet {
    position: fixed; inset: 0; z-index: 180;
    background: rgba(12, 9, 4, 0.45);
    display: flex; align-items: flex-end; justify-content: center;
}
body > .color-sheet { z-index: var(--z-picker); }
.color-sheet[hidden] { display: none; }
.color-sheet-card {
    width: 100%; max-width: 560px; background: var(--color-card);
    border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lift);
    padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
    display: flex; flex-direction: column; gap: 12px;
}
.color-sheet-title { margin: 0; font-weight: 700; font-size: var(--text-base); }

/* The small sheets (icon, colour, budgets, "how to add") rise from the bottom
   like the main sheet, and go down the same path (Matan, 7.10, motion round,
   item 2). Before, they popped in all at once, while the main sheet and the
   delete confirm already moved: it wasn't consistent.
   `@starting-style`: the entrance, with no JS. `allow-discrete` keeps the sheet
   displayed during the exit; a browser that doesn't know them just opens and
   closes with no motion. */
.icon-picker, .color-sheet {
    opacity: 1;
    transition: opacity 250ms ease, display 250ms allow-discrete, overlay 250ms allow-discrete;
}
.icon-picker-card, .color-sheet-card {
    transform: translateY(0);
    transition: transform 350ms cubic-bezier(0.32, 0.72, 0, 1);
}
.icon-picker[hidden], .color-sheet[hidden] { opacity: 0; pointer-events: none; }
.icon-picker[hidden] .icon-picker-card,
.color-sheet[hidden] .color-sheet-card {
    transform: translateY(100%);
    transition-duration: var(--dur-base);            /* exiting faster than entering */
    transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
}
@starting-style {
    .icon-picker:not([hidden]), .color-sheet:not([hidden]) { opacity: 0; }
    .icon-picker:not([hidden]) .icon-picker-card,
    .color-sheet:not([hidden]) .color-sheet-card { transform: translateY(100%); }
}
.color-sheet-hint { margin: -6px 0 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.color-sheet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.color-option {
    display: flex; align-items: center; justify-content: flex-start; gap: 10px;
    min-height: 56px; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer;
    background: var(--color-input); border: 2px solid transparent; font: inherit; text-align: start;
}
.color-option.is-current { border-color: var(--color-gold-border); background: var(--color-gold-dim); }
.color-option:disabled { opacity: 0.4; cursor: not-allowed; }
.color-option:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.color-option-note { font-size: var(--text-2xs); color: var(--color-text-muted); font-weight: 600; }
.color-option .owner-pill { font-size: var(--text-md); padding: 3px 10px; }
/* The colour itself, full strength: `currentColor` of the member's tag class,
   so the swatch follows the palette in both themes (Matan, 22.11) */
.color-option .color-swatch {
    flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%;
    background: currentColor !important;
    display: grid; place-items: center; font-size: var(--text-md); font-weight: 700;
}
.color-option .color-swatch b { color: #FFFFFF; }
:root[data-theme="dark"] .color-option .color-swatch b { color: #1A1408; }
.color-option-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.color-sheet-close { align-self: stretch; min-height: 44px; }

/* A loading skeleton (Matan, 30.9, round 6, item 14): above the page, below
   the bottom menu (50), so the tapped tab looks already selected */
.skeleton-screen {
    position: fixed; inset: 0; z-index: 45;
    background: var(--color-bg);
    display: flex; flex-direction: column;
}
.skeleton-hero {
    background: linear-gradient(170deg, var(--hero-bg), var(--hero-bg-2));
    padding: calc(env(safe-area-inset-top, 0px) + 22px) 18px 56px;
    display: flex; flex-direction: column; gap: 12px;
}
.skeleton-body { padding: 0 16px; margin-top: -32px; display: flex; flex-direction: column; gap: 12px; }
.skeleton-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.skeleton-chips .sk-card { height: 84px; }
.sk { display: block; border-radius: var(--radius); }
.sk-line { height: 14px; background: rgba(255, 255, 255, 0.10); border-radius: var(--radius-pill); }
.sk-line.sk-big { height: 30px; }
.sk-card {
    background: linear-gradient(100deg, var(--color-card) 30%, var(--color-card-hover) 50%, var(--color-card) 70%);
    background-size: 300% 100%;
    border: var(--border-subtle);
    animation: sk-shimmer 1.2s ease-in-out infinite;
}
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .sk-card { animation: none; } }
/* The same cards inside a screen still waiting for its data (`core.js`): under
   its hero, not over the page */
.skeleton-body.view-skeleton { margin-top: 0; padding: 0; }

/* The budgets sheet on the month page (Matan, 30.9): the same bottom sheet as
   picking a colour */
.budget-sheet-card { max-height: 86vh; max-height: 86dvh; }
.budget-sheet-list { overscroll-behavior: contain; overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
.budget-sheet-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 0; border-top: 1px solid var(--divider-subtle); cursor: default;
}
.budget-sheet-row:first-child { border-top: 0; }
.budget-sheet-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.budget-sheet-name { font-weight: 600; font-size: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-sheet-spent { font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.budget-sheet-amount { flex: none; width: 128px; }
.budget-sheet-amount .amount-input { font-size: 1rem; padding-block: 8px; }
.budget-sheet-actions { margin-top: 4px; }
/* Keyboard open on iPhone (`core.js`): the sheet lives in the visible screen */
/* Under the status bar, not behind it: the title stays in sight */
.color-sheet.kb-fit .color-sheet-card { max-height: calc(100% - env(safe-area-inset-top, 0px) - 6px); padding-bottom: 12px; }
.color-sheet.kb-fit::after {
    content: ''; position: absolute; inset-inline: 0; top: 100%; height: 100vh;
    background: var(--color-card);
}

/* "This week" on the home page (Matan, 30.9) */
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.week-head .chart-title { margin: 0; }
/* Paging to earlier weeks (Matan, 2.10) */
.week-title-wrap { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.week-nav { display: flex; gap: 6px; flex-shrink: 0; }
.week-nav-btn {
    position: relative; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--color-input); color: var(--color-gold-text); border: 0;
}
.week-nav-btn svg { width: 15px; height: 15px; }
.week-nav-btn:disabled { opacity: 0.35; }
.week-nav-btn::before { content: ''; position: absolute; inset: -7px; }   /* 44px tap area */
.week-card.is-loading { opacity: 0.55; transition: opacity var(--dur-quick); }
.week-range { font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.week-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 10px; margin: 6px 0 4px; }
.week-sum { font-size: var(--text-display); font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.week-cmp { font-size: var(--text-xs); font-weight: 600; padding: 2px 9px; border-radius: var(--radius-pill); }
.week-cmp.down { color: var(--color-income); background: color-mix(in srgb, var(--color-income) 12%, transparent); }
.week-cmp.up   { color: var(--color-expense); background: color-mix(in srgb, var(--color-expense) 12%, transparent); }
.week-cmp.same { color: var(--color-text-muted); background: var(--color-input); }
.week-bars {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
    align-items: end; height: 90px; margin-top: 8px;
}
.week-day {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px;
    height: 100%; min-width: 0; background: none; border: 0; padding: 0; cursor: pointer; font: inherit;
}
.week-day:disabled { cursor: default; }
.week-amt { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); min-height: 1em; font-variant-numeric: tabular-nums; }
.week-bar { width: 100%; max-width: 30px; border-radius: 7px 7px 3px 3px; background: color-mix(in srgb, var(--color-gold) 55%, var(--color-card)); }
.week-day.today .week-bar { background: var(--color-gold); }
.week-day.zero .week-bar { background: var(--color-input); }
.week-day.future .week-bar { background: none; border: 1.5px dashed var(--color-input); }
.week-day.is-selected .week-bar { outline: 2px solid var(--color-gold-border); outline-offset: 2px; }
.week-lbl { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); }
.week-day.today .week-lbl { color: var(--color-gold-text); }
.week-detail { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--divider-subtle); }
.week-detail-head {
    display: flex; justify-content: space-between; gap: 8px; margin: 0 0 4px;
    font-size: var(--text-sm); font-weight: 600; color: var(--color-text-soft); font-variant-numeric: tabular-nums;
}
.week-detail-list { list-style: none; margin: 0; padding: 0; }
.week-detail-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: var(--text-md); }
.week-detail-list li > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-detail-side { display: flex; align-items: center; gap: 8px; flex: none; }
.week-detail-amount { color: var(--color-expense); font-weight: 600; flex: none; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.week-empty { margin: 0; font-size: var(--text-sm); color: var(--color-text-muted); }
/* An empty day on one line (design pass, 11.11) */
.week-detail[data-empty] { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.week-detail[data-empty] .week-detail-head { margin: 0; }
.week-detail[hidden] { display: none; }
.week-fixed { font-size: var(--text-xs); color: var(--color-text-muted); }
.week-detail-list li.is-fixed { color: var(--color-text-muted); }
/* A tappable row (Matan, 22.11): opens the edit sheet, and the tap shows on
   it the way it does on the other lists. The highlight reaches a little past
   the text on both sides, so the row keeps its place. */
.week-detail-list li.week-tx {
    cursor: pointer; border-radius: var(--radius-xs); margin-inline: -8px; padding-inline: 8px;
    align-items: center; -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s;
}
.week-detail-list li.week-tx:active { background: rgba(var(--ink-rgb), 0.05); }
.week-detail-list li.week-tx:focus-visible { outline: 2px solid var(--color-gold-bright); outline-offset: -2px; }
.week-detail-list li.is-fixed .week-detail-amount { color: inherit; font-weight: 500; }
.week-fixed-tag { font-size: var(--text-2xs); font-weight: 600; padding: 1px 7px; margin-inline-start: 4px; border-radius: var(--radius-pill); background: var(--color-input); }
/* An empty week: one row instead of an empty chart (Matan, 18.10) */
.week-empty-state {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 10px; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--color-input);
}
.week-empty-text { min-width: 0; }
/* A lower row (Matan, 24.11): the text a size down and regular, and "add" as
   gold words, not a button the size of the row. Still a 44px touch target. */
.week-empty-title { margin: 0; font-size: var(--text-md); font-weight: 400; }
.week-empty-sub { margin: 1px 0 0; font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.week-empty-add {
    flex: none; min-height: 44px; padding: 0 2px; white-space: nowrap;
    border: 0; background: transparent;
    color: var(--color-gold-text); font: inherit; font-size: var(--text-md); font-weight: 700; cursor: pointer;
}

/* The sheet with a category's expenses in a month: the comparison page
   (Matan, 30.9) */
.cat-month-sheet .color-sheet-card { max-height: 80vh; max-height: 80dvh; }
.cat-month-list { list-style: none; margin: 0; padding: 0; overscroll-behavior: contain; overflow-y: auto; min-height: 0; }
.cat-month-list li {
    display: flex; align-items: center; gap: 10px; padding: 10px 0;
    border-top: 1px solid var(--divider-subtle); font-size: var(--text-body);
}
.cat-month-list li:first-child { border-top: 0; }
.cat-month-date { flex: none; width: 3.2em; font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.cat-month-desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-month-amount { flex: none; color: var(--color-expense); font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* "How to add a family member" (Matan, 5.10): in the same bottom sheet as
   picking a colour */
.welcome-invite { z-index: var(--z-banner); }
.welcome-steps {
    margin: 0; padding-inline-start: 22px;
    display: flex; flex-direction: column; gap: 8px;
    font-size: var(--text-body); line-height: 1.5;
}
.welcome-steps li::marker { color: var(--color-gold-text); font-weight: 700; }
.welcome-code { font-weight: 700; letter-spacing: 0.08em; color: var(--color-text); }
.welcome-invite .submit-btn { margin-top: 4px; }

/* ─── The projects page (Matan, 5.10) ────────────────────────────────────
   A box per project, in the language of the rest of the app: a white card with
   the same shadow and radius, and a soft tint over it, like the family member
   tags (a strong colour on a weak background). Four tints, always in the same
   order: blue, peach, pink, green. Not sand: sand is the background colour, and
   a box in the background colour blends into it. And not the family member
   colours: there a colour says "whose", and here it only distinguishes. */
:root {
    --tint-0: rgba(46, 103, 168, 0.13);   /* blue */
    --tint-1: rgba(226, 110, 52, 0.13);   /* peach */
    --tint-2: rgba(200, 40, 70, 0.10);    /* pink */
    --tint-3: rgba(21, 128, 61, 0.12);    /* green */
}
:root[data-theme="dark"] {
    --tint-0: rgba(96, 165, 250, 0.16);
    --tint-1: rgba(251, 146, 90, 0.15);
    --tint-2: rgba(248, 113, 133, 0.14);
    --tint-3: rgba(74, 222, 128, 0.13);
}
.project-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.project-tile {
    position: relative; display: flex; align-items: center; gap: 12px;
    padding: 9px 14px; text-align: start;
    background: var(--color-card); border: var(--border-subtle); border-radius: var(--radius);
    box-shadow: var(--shadow-card); color: var(--color-text); text-decoration: none;
    font: inherit; cursor: pointer; overflow: hidden;
    transition: transform 0.15s ease;
}
/* White cards like the rest of the app; the project's tint is on its icon
   only (Matan, 22.11). Until then the whole tile was tinted. */
.project-tile > * { position: relative; }
.project-tile:active { transform: scale(0.98); }
.project-tile:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.tint-0 { --tile-tint: var(--tint-0); } .tint-1 { --tile-tint: var(--tint-1); }
.tint-2 { --tile-tint: var(--tint-2); } .tint-3 { --tile-tint: var(--tint-3); }
.project-tile-icon {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: var(--radius-sm); font-size: var(--text-lg); line-height: 1;
    display: flex; align-items: center; justify-content: center; background: var(--tile-tint, var(--color-input));
}
.project-tile-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.project-tile-name { font-weight: 700; font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
.project-tile-sub { margin-top: 2px; font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.4; }
.trend-verdict { margin: 4px 0 14px; font-size: var(--text-body); line-height: 1.55; color: var(--color-text-muted); }
.trend-verdict b { color: var(--color-text); }
.trend-verdict b.deficit { color: var(--color-expense); }
.trend-verdict b.surplus { color: var(--color-income); }
.project-tile-progress b { color: var(--color-text); font-weight: 700; }
.project-tile-progress .deficit, .project-tile-progress .deficit b { color: var(--color-expense); }
.project-tile-bar { display: block; height: 5px; margin-top: 7px; border-radius: var(--radius-pill); background: rgba(var(--ink-rgb), 0.08); overflow: hidden; }
.project-tile-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--color-gold); }
.project-tile-bar > span.danger { background: var(--color-expense); }
.project-tile-tag { flex-shrink: 0; font-size: var(--text-2xs); color: var(--color-text-soft); background: rgba(var(--ink-rgb), 0.06); border-radius: var(--radius-pill); padding: 1px 8px; }

/* ── The projects list, second design (Matan, 22.11) ──
   A project's tile: name and percent on one line, a sentence that says what the
   bar shows, then the last movement and a + that adds straight into it. */
div.project-tile { align-items: flex-start; padding: 12px 14px; cursor: default; }
div.project-tile:active { transform: none; }
.project-tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
/* The whole tile is the link; the + sits above it */
.project-tile-link { color: inherit; text-decoration: none; }
.project-tile-link::after { content: ""; position: absolute; inset: 0; }
.project-tile-link:focus-visible { outline: none; }
.project-tile:has(.project-tile-link:focus-visible) { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.project-tile-pct { flex-shrink: 0; font-weight: 700; font-size: var(--text-md); color: var(--color-gold-text); font-variant-numeric: tabular-nums; }
.project-tile-pct.is-over { color: var(--color-expense); }
.project-tile-bar > span.saving { background: var(--color-income); }
.project-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.project-tile-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.project-tile-tag.is-over { background: rgba(184, 58, 75, 0.12); color: var(--color-expense); font-weight: 600; }
.project-tile-last { font-size: var(--text-2xs); color: var(--color-text-muted); }
.project-tile-add {
    position: relative; z-index: 1; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; border: 0;
    display: grid; place-items: center; background: var(--color-input); color: var(--color-gold-text);
    font: inherit; font-size: var(--text-lg); font-weight: 600; line-height: 1; cursor: pointer;
}
.project-tile-add::before { content: ""; position: absolute; inset: -5px; }      /* a 46px touch target */
.project-tile-add:active { transform: scale(0.94); }

/* The top of the page: the title with "new project" beside it, and the summary */
.projects-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.projects-new-btn {
    flex-shrink: 0; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
    border: 1px solid var(--hero-gold-border, rgba(224, 184, 74, 0.5)); border-radius: var(--radius-pill);
    color: var(--hero-gold, #E0B84A); font-weight: 600; font-size: var(--text-md); text-decoration: none;
}
.projects-summary {
    margin-top: 14px; padding: 12px 16px; border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1);
}
/* Several projects: only how many (their money isn't summed) */
.projects-count { margin: 6px 0 0; font-size: var(--text-md); color: var(--hero-text-muted); }
.projects-summary-count, .projects-summary-sub { margin: 0; font-size: var(--text-xs); color: var(--hero-text-muted); }
.projects-summary-main { margin: 2px 0; font-size: var(--text-xl); font-weight: 700; line-height: 1.25; color: var(--hero-gold, #E0B84A); font-variant-numeric: tabular-nums; }
.projects-summary-main.is-over { color: #F2A0A8; }

/* "Finished": a row with how it ended */
.finished-list { display: flex; flex-direction: column; gap: 8px; }
.finished-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px;
    background: var(--color-card); border: var(--border-subtle); border-radius: var(--radius);
    color: var(--color-text); text-decoration: none; font-size: var(--text-md);
}
.finished-row-name { min-width: 0; overflow-wrap: anywhere; }
.finished-row-sum { flex-shrink: 0; font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* "Which project is this?" in the new-project form: two cards, one choice */
.kind-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind-card {
    display: flex; flex-direction: column; gap: 4px; padding: 14px 12px; text-align: start;
    background: var(--color-card); border: 1.5px solid var(--divider-subtle); border-radius: var(--radius-lg, 16px);
    font: inherit; color: inherit; cursor: pointer;
}
.kind-card[aria-checked="true"] { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(166, 124, 0, 0.14); background: rgba(166, 124, 0, 0.05); }
.kind-card:disabled { cursor: default; opacity: 0.6; }
.kind-card-icon { font-size: var(--text-xl); line-height: 1; }
.kind-card-name { font-weight: 700; font-size: 1rem; }
.kind-card-text { font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.45; }
.kind-card-rule { margin-top: 2px; font-size: var(--text-2xs); font-weight: 600; color: var(--color-gold-text); }

/* "New project": white with a dashed border: a goldish background blended with
   the page background, and in the empty state the box overlaps the edge of the
   dark header, so it is opaque */
.project-tile-new { border: 1.5px dashed var(--color-gold-border); box-shadow: none; color: var(--color-gold-text); }
.project-tile-new .project-tile-sub { color: var(--color-text-soft); }
/* A circle with a border and not a solid gold square: that is already the
   floating add-transaction button, and two identical + buttons side by side
   don't say what each one does */
.project-tile-plus {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--color-gold-border); background: var(--color-card);
    color: var(--color-gold-text); font-size: var(--text-lg); font-weight: 500;
}
.project-ideas-title { margin: 10px 2px 0; font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.project-idea .project-tile-sub { color: var(--color-gold-text); }

.projects-section-title { font-size: var(--text-md); font-weight: 600; color: var(--color-text-muted); margin: 6px 2px 10px; }
.finished-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.finished-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
    background: var(--color-card); border: var(--border-subtle); border-radius: var(--radius-pill);
    box-shadow: var(--shadow-card); color: var(--color-text-soft); text-decoration: none; font-size: var(--text-md);
}

/* ─── All of the month's transactions: a screen of its own (Matan, 5.10) ──
   Like the home page search screen: above the page, and below the edit sheet,
   so tapping a transaction opens editing above it. */
.tx-preview { margin-top: 2px; }
.tx-screen {
    position: fixed; inset: 0; z-index: 95;
    background: var(--color-bg);
    display: flex; flex-direction: column;
}
.tx-screen[hidden] { display: none; }

/* Full screens (search and "all of the month's transactions") rise slightly
   from below and fade in, and go down the same path (Matan, 7.10, motion round,
   item 3). Before, they appeared in an instant. A short move (24px) and not a
   whole screen: you enter search to type right away. At rest `transform: none`;
   otherwise the screen becomes the containing block for everything floating
   inside it. */
.search-screen, .tx-screen {
    opacity: 1;
    transform: none;
    transition: opacity 300ms cubic-bezier(0.32, 0.72, 0, 1), transform 300ms cubic-bezier(0.32, 0.72, 0, 1),
                display 300ms allow-discrete, overlay 300ms allow-discrete;
}
.search-screen[hidden], .tx-screen[hidden] {
    opacity: 0;
    transform: translateY(24px);
    pointer-events: none;
    transition-duration: var(--dur-base);            /* exiting faster than entering */
    transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
}
@starting-style {
    .search-screen:not([hidden]), .tx-screen:not([hidden]) { opacity: 0; transform: translateY(24px); }
}
body.tx-screen-open { overflow: hidden; }
.tx-screen-bar {
    display: flex; align-items: center; gap: 12px;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
    background: linear-gradient(170deg, var(--hero-bg), var(--hero-bg-2));
    color: var(--hero-text);
}
.tx-screen-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-screen-title { margin: 0; font-size: var(--text-lg); font-weight: 700; }
.tx-screen-month { font-size: var(--text-sm); color: var(--hero-text-muted); }
.tx-screen-bar .all-tx-count { background: var(--hero-chip-bg); color: var(--hero-text); border: 1px solid var(--hero-chip-border); }
.tx-screen-body {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;   /* At the end of the list scrolling stops, it doesn't continue to the page
   (touch round) */
    padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.cat-tx-list.tx-screen-list { background: var(--color-card); border: var(--border-subtle); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 4px 14px; }

/* ─── The add/edit sheet on one screen (Matan, 5.10) ─────────────────────
   The categories at today's size; what got shorter is everything else:
   spacing, "scan receipt", "whose", the date on one line, frequency and end date
   side by side, and duplicate/delete as links. Limited to the sheet: forms on
   other pages don't change. */
/* The sheet up to 96% of the screen height (was 92%), and smaller bottom
   padding, so it fits on one screen without shrinking the categories */
#modalOverlay .modal-sheet { max-height: 96vh; max-height: calc(var(--sheet-room, 100dvh) * 0.96); padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
#modalOverlay .modal-handle { margin-bottom: 8px; }
#modalOverlay .toggle-btn { padding-block: 7px; }
#modalOverlay .tx-form .form-input:not(.amount-input) { padding-block: 9px; }
#modalOverlay .submit-btn { padding-block: 13px; }
#modalOverlay .modal-header { gap: 8px; margin-bottom: 10px; }
.modal-title-row { display: flex; align-items: center; gap: 10px; padding-inline-end: 44px; min-height: 32px; }
.modal-title-row .modal-title { flex: 1; }
#modalOverlay .tx-form .form-group { margin-bottom: 8px; }
#modalOverlay .form-label { margin-bottom: 5px; }
#modalOverlay .amount-input { padding-block: 7px; }
#modalOverlay .owner-btn { padding: 7px 4px; font-size: var(--text-md); }
#modalOverlay .form-error:empty { min-height: 0; margin: 0; }
#modalOverlay .recurring-group { margin-top: 12px; margin-bottom: 10px; }
.modal-sheet.is-edit .recurring-group { margin-top: 8px; }

/* `wrap`: on a narrow screen or with "extra large" text, "another date" drops a
   line instead of leaving the screen (7.10) */
.date-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.date-row .date-quick-chips { margin-bottom: 0; }
.date-pick {
    position: relative; display: inline-flex; align-items: center; gap: 6px;
    margin-inline-start: auto; padding: 6px 14px; border-radius: var(--radius-pill);
    background: var(--color-card); border: 1px solid rgba(var(--ink-rgb), 0.14);
    font-size: var(--text-sm); font-weight: 600; color: var(--color-text-soft); white-space: nowrap;
}
.date-pick.active { color: var(--color-gold-text); background: var(--color-gold-dim); border-color: var(--color-gold-border); }
.date-pick-change { display: none; }
/* The real date field: transparent, covering the whole button: a tap opens the picker */
.date-pick-input {
    position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
    font-size: max(1rem, 16px); cursor: pointer; border: 0; padding: 0; margin: 0;
    -webkit-appearance: none; appearance: none; color-scheme: light;
}
/* The field only holds the value: the button over it opens the app's calendar */
.date-pick-input { pointer-events: none; }
.date-field { position: relative; }
.date-field-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.date-field-btn {
    position: relative; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    text-align: start; cursor: pointer; font-variant-numeric: tabular-nums;
}
.date-field-btn.is-empty { color: var(--color-text-muted); }
.date-field-icon { display: inline-flex; color: var(--color-text-soft); }
.date-field-icon svg { width: 18px; height: 18px; }
.date-field-btn:focus-visible { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(166, 124, 0, 0.14); outline: none; }
/* A day that can't be picked: before the transaction's own date */
.cal-day:disabled { opacity: 0.3; cursor: default; }
.date-pick-btn {
    position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; margin: 0;
    border: 0; border-radius: inherit; background: transparent; cursor: pointer;
}
/* The app's calendar (Matan, 1.12): days of a month, and a tap on the title
   shows the year's months; a tap on a month opens its days */
.cal-pop {
    position: fixed; inset: 0; z-index: var(--z-picker); display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(20, 16, 7, 0.45);
}
.cal-pop[hidden] { display: none; }
.cal-card {
    width: 100%; max-width: 340px; padding: 14px; border-radius: var(--radius-lg);
    background: var(--color-card); color: var(--color-text); box-shadow: var(--shadow-overlay);
}
:root[data-theme="dark"] .cal-card { border: 1px solid rgba(255, 255, 255, 0.14); }
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.cal-title {
    flex: 1; min-height: 44px; border: 0; border-radius: var(--radius-sm); background: var(--color-input);
    color: var(--color-text); font: inherit; font-size: var(--text-body); font-weight: 700; cursor: pointer;
}
.cal-nav {
    width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%; background: transparent; color: var(--color-text-soft); cursor: pointer;
}
.cal-nav svg { width: 20px; height: 20px; }
.cal-week, .cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-week span { padding: 4px 0; text-align: center; font-size: var(--text-2xs); font-weight: 600; color: var(--color-text-soft); opacity: 0.8; }
.cal-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cal-day, .cal-month {
    border: 1px solid transparent; background: transparent; color: var(--color-text);
    font: inherit; font-variant-numeric: tabular-nums; cursor: pointer;
}
.cal-day { aspect-ratio: 1; min-height: 40px; border-radius: 50%; font-size: var(--text-md); }
.cal-month { min-height: 52px; border-radius: var(--radius-sm); font-size: var(--text-md); font-weight: 500; }
.cal-day.today, .cal-month.today { border-color: var(--color-gold-border); color: var(--color-gold-text); font-weight: 700; }
.cal-day.selected, .cal-month.selected { background: var(--color-gold); border-color: var(--color-gold); color: #FFFFFF; font-weight: 700; }
.cal-foot { display: flex; justify-content: space-between; flex-direction: row-reverse; margin-top: 8px; }
.cal-clear[hidden] { display: none; }
.cal-cancel, .cal-clear {
    min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--radius-sm); background: transparent;
    color: var(--color-text-soft); font: inherit; font-size: var(--text-md); font-weight: 600; cursor: pointer;
}
.cal-pop button:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 1px; }
@media (hover: hover) {
    .cal-day:not(.selected):not(:disabled):hover, .cal-month:not(.selected):hover, .cal-nav:hover { background: var(--color-input); }
}
.date-pick:focus-within { box-shadow: 0 0 0 3px rgba(166, 124, 0, 0.14); border-color: var(--color-gold); }
/* Editing: no today/yesterday/day before: the full date in Hebrew, and "change" */
.modal-sheet.is-edit .date-quick-chips { display: none; }
.modal-sheet.is-edit .date-pick {
    flex: 1; margin: 0; gap: 10px; min-height: 44px; padding: 5px 12px;
    border-radius: var(--radius-sm); font-size: var(--text-body); font-weight: 500; color: var(--color-text);
}
.modal-sheet.is-edit .date-pick-icon {
    width: 32px; height: 32px; border-radius: var(--radius-xs); background: var(--color-input);
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.modal-sheet.is-edit .date-pick-text { flex: 1; }
.modal-sheet.is-edit .date-pick-change { display: inline; color: var(--color-gold-text); font-size: var(--text-sm); font-weight: 600; }

#modalOverlay .recurring-fields { padding: 12px; margin-top: 10px; }
/* One under the other (Matan, 7.10): at 16px "כל חודש (באותו התאריך)" and the
   date didn't fit side by side */
#modalOverlay .recurring-fields.visible { display: grid; grid-template-columns: 1fr; gap: 8px; }
/* "כל חודש (באותו התאריך)" is long: more width for the frequency, and slightly
   smaller text */
/* 16px and not 0.88rem: below 16 the iPhone zooms the whole screen on tapping a
   field and doesn't zoom back (7.10) */
#modalOverlay .recurring-fields .form-input { font-size: max(1rem, 16px); padding-inline: 10px; }
#modalOverlay .recurring-fields select.form-input { padding-left: 28px; background-position: left 10px center; }
#modalOverlay .recurring-fields .form-group { margin-bottom: 0; min-width: 0; }

#modalOverlay .edit-mode-actions { justify-content: center; gap: 28px; margin-top: 8px; }
#modalOverlay .duplicate-tx-btn,
#modalOverlay .delete-tx-btn { flex: none; padding: 5px 4px; background: none; border: 0; font-size: var(--text-md); }

/* ─── The add sheet, new design (Matan, 11.10) ────────────────────────────
   Four changes, all inside the sheet: receipt scanning in the header row, a
   large amount in the centre in the department's colour, taller categories with
   the full name, and the details in one block with thin lines, with a dark,
   wide button under it, without the department's colour. */

/* Receipt scanning: in the header row, 44px (the size of a finger tap) */
#modalOverlay .modal-title-row { flex-wrap: wrap; }
#modalOverlay .scan-btn {
    width: auto; flex: none; margin: 0; min-height: 44px; padding: 0 16px;
    border-radius: var(--radius-pill); font-size: var(--text-body); gap: 7px;
}
#modalOverlay .scan-btn-icon { font-size: var(--text-title); }

/* The amount: large, centred, in the department's colour. The width follows the
   length (`fitAmount`) */
#modalOverlay .amount-group { text-align: center; margin-bottom: 10px; }
#modalOverlay .amount-group .form-label { color: var(--color-text-soft); margin-bottom: 0; }
#modalOverlay .modal-sheet.expense-mode .amount-group { color: var(--color-expense); }
#modalOverlay .modal-sheet.income-mode .amount-group { color: var(--color-income); }
#modalOverlay .modal-sheet.savings-mode .amount-group { color: var(--color-savings); }
#modalOverlay .amount-input-wrap { display: flex; align-items: baseline; justify-content: center; gap: 4px; direction: ltr; }
#modalOverlay .amount-currency { position: static; transform: none; color: inherit; font-size: var(--text-lg); font-weight: 600; }
#modalOverlay .amount-input {
    width: 5ch; min-width: 2ch; max-width: 100%; padding: 0; border: 0; border-radius: 0;
    background: transparent; box-shadow: none; color: inherit;
    font-size: 2.25rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; text-align: left;
}
#modalOverlay .amount-input:focus { box-shadow: none; }
#modalOverlay .amount-group::after {
    content: ""; display: block; width: 110px; height: 2px; margin: 2px auto 0;
    border-radius: 1px; background: currentColor; opacity: 0.3;
}
#modalOverlay .amount-group:focus-within::after { opacity: 0.7; }

/* The categories: taller, and the full name visible (wrapping if needed) */
#modalOverlay .cat-btn { min-height: 76px; justify-content: center; padding: 8px 3px; font-size: var(--text-xs); line-height: 1.2; text-align: center; }
#modalOverlay .cat-btn .cat-emoji { font-size: var(--text-xl); line-height: 1.2; }
#modalOverlay .cat-btn > span:last-child { overflow-wrap: anywhere; }

/* The details: one block, a row per detail. A row that doesn't fit the width
   drops: the control moves under its label (a large family, "extra large" text) */
#modalOverlay .tx-details {
    background: var(--color-card); border: 1px solid rgba(var(--ink-rgb), 0.09);
    border-radius: var(--radius); margin-bottom: 12px;
}
#modalOverlay .tx-details .detail-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
    margin: 0; padding: 6px 14px; min-height: 52px;
}
#modalOverlay .tx-details .detail-row + .detail-row { border-top: 1px solid rgba(var(--ink-rgb), 0.07); }
/* All the labels at the same width, so "של מי ההוצאה?" and "תאריך" get boxes of
   identical width (Matan, 1.11). 100px: "של מי החיסכון?" fits on one line. */
#modalOverlay .detail-row > .form-label { flex: 0 0 100px; min-width: 0; margin: 0; font-size: var(--text-md); }
#modalOverlay .tx-details .detail-row > .form-input {
    flex: 1 1 150px; min-width: 0; border: 0; background: transparent; box-shadow: none;
    padding-inline: 0; font-size: max(1rem, 16px);
}
#modalOverlay .detail-row .desc-suggest { flex-basis: 100%; margin: 0 0 6px; }
#modalOverlay .detail-row .owner-toggle {
    flex: 1 1 190px; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 3px; padding: 3px; border-radius: var(--radius-sm); background: var(--color-input);
}
#modalOverlay .detail-row .owner-btn { border: 0; background: transparent; min-height: 36px; }
#modalOverlay .detail-row .owner-btn.active {
    background: var(--color-card); color: var(--color-gold-text);
    box-shadow: 0 1px 3px rgba(31, 24, 8, 0.12);
}
#modalOverlay .detail-row .date-row { flex: 1 1 200px; gap: 6px; }
#modalOverlay .detail-row .date-pick { padding: 5px 12px; }
.date-sub { display: none; }
/* When adding: one bar like "של מי ההוצאה": today | yesterday | other, and the
   date itself under each (Matan, 1.11: "not clear enough", option B) */
#modalOverlay .modal-sheet:not(.is-edit) .detail-row .date-row {
    display: grid; grid-template-columns: 1fr 1fr 1.15fr; flex: 1 1 190px;
    gap: 3px; padding: 3px; border-radius: var(--radius-sm); background: var(--color-input);
}
#modalOverlay .modal-sheet:not(.is-edit) .date-row .date-quick-chips { display: contents; }
#modalOverlay .modal-sheet:not(.is-edit) .detail-row .date-chip,
#modalOverlay .modal-sheet:not(.is-edit) .detail-row .date-pick {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 44px; margin: 0; padding: 4px 6px; border: 0; border-radius: var(--radius-xs);
    background: transparent; font-size: var(--text-md); font-weight: 500; line-height: 1.15;
    color: var(--color-text-soft);
}
#modalOverlay .modal-sheet:not(.is-edit) .detail-row .date-pick { flex-direction: row; gap: 4px; }
#modalOverlay .modal-sheet:not(.is-edit) .detail-row .date-chip.active,
#modalOverlay .modal-sheet:not(.is-edit) .detail-row .date-pick.active {
    background: var(--color-card); color: var(--color-gold-text); font-weight: 700;
    box-shadow: 0 1px 3px rgba(31, 24, 8, 0.12);
}
#modalOverlay .modal-sheet:not(.is-edit) .date-sub { display: block; font-size: var(--text-2xs); font-weight: 500; opacity: 0.75; }
#modalOverlay .modal-sheet:not(.is-edit) .date-pick-icon { display: inline-flex; }
#modalOverlay .modal-sheet:not(.is-edit) .date-pick-icon svg { width: 15px; height: 15px; }

/* Recurring transaction: a switch instead of a checkbox, in the same design as
   in settings (`.pref-switch`) */
#modalOverlay .tx-details .recurring-group { margin: 0; }
#modalOverlay .recurring-group .checkbox-label { flex: 1 1 100%; justify-content: space-between; min-height: 40px; }
#modalOverlay .recurring-group .checkbox-text { order: -1; font-size: var(--text-md); font-weight: 600; color: var(--color-text-soft); }
#modalOverlay .tx-details .recurring-fields { flex-basis: 100%; margin: 0 0 8px; padding: 0; background: transparent; border: 0; }
#modalOverlay .recurring-group .field-hint { flex-basis: 100%; }

/* The save button: dark and wide, in every department. In dark mode it
   blended into the background, so there it is gold */
#modalOverlay .submit-btn {
    background: linear-gradient(160deg, var(--hero-bg-2) 0%, var(--hero-bg) 70%);
    color: var(--hero-text); border-radius: var(--radius); padding-block: 15px;
    box-shadow: 0 6px 18px rgba(20, 16, 7, 0.28);
}
:root[data-theme="dark"] #modalOverlay .submit-btn { background: var(--gradient-gold); color: #FFFFFF; box-shadow: var(--shadow-gold); }
/* Save stays in view (design pass, 11.11): with twelve categories and a project
   the sheet is taller than a 390×844 screen, and Save opened below the fold. It
   sticks to the bottom of the sheet instead. The 12px ring in the sheet's colour
   covers the rows scrolling behind it, so nothing peeks around the button. */
#modalOverlay label.submit-btn {
    position: sticky; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 2;
    box-shadow: 0 6px 18px rgba(20, 16, 7, 0.28), 0 0 0 12px var(--color-bg-elevated);
}
/* Safari measures that `bottom` from inside the sheet's bottom padding, Chrome
   from its edge. So on iPhone, scrolled all the way down, Save still rose by the
   padding and covered the last row, the "תשלומים" switch (Matan, 21.11: "it's
   under the button and can't be pressed"). The space under the form is a spacer
   inside it instead of padding, and both engines leave the button in place. */
#modalOverlay .modal-sheet { padding-bottom: 8px; }
#modalOverlay .tx-form::after { content: ""; display: block; height: calc(10px + env(safe-area-inset-bottom, 0px)); }
/* Rows scrolling past Save peeked out in the strip under it (Matan, 21.11, a
   screenshot: "תשלומים" visible under the button). While the content still
   goes on below (`.is-stuck`, transactions.js) a strip in the sheet's colour
   hides it; at the end it's gone, so the edit actions under Save show. */
#modalOverlay label.submit-btn.is-stuck::after {
    content: ""; position: absolute; inset-inline: -12px; top: 100%; height: 120px;
    background: var(--color-bg-elevated); pointer-events: none;
}
/* Keyboard open (`.kb-fit`): Save right on top of it. The home-indicator
   space is under the keyboard, so it is not needed. */
#modalOverlay.kb-fit .modal-sheet { padding-bottom: 0; max-height: calc(var(--sheet-room, 100dvh) - env(safe-area-inset-top, 0px) - 6px); }
#modalOverlay.kb-fit .tx-form::after { height: 8px; }
#modalOverlay.kb-fit label.submit-btn { bottom: 8px; }
/* Whatever is under the fitted sheet is the sheet's colour, a whole screen
   down: if it is ever a step above the keyboard, the page doesn't show in the
   gap (Matan, 22.11) */
#modalOverlay.kb-fit::after {
    content: ''; position: absolute; inset-inline: 0; top: 100%; height: 100vh;
    background: var(--color-bg-elevated);
}
/* The 12px ring around Save cut the bottom edge off the project field above it
   (Matan, 21.11, a screenshot): only 8px separated them. 18px (it collapses
   with the error line's 8px margin above), so the ring ends in the gap. */
#modalOverlay label.submit-btn { margin-top: 18px; }
:root[data-theme="dark"] #modalOverlay label.submit-btn { box-shadow: var(--shadow-gold), 0 0 0 12px var(--color-bg-elevated); }
#modalOverlay label.submit-btn.is-unchanged,
:root[data-theme="dark"] #modalOverlay label.submit-btn.is-unchanged { box-shadow: 0 0 0 12px var(--color-bg-elevated); }

/* Keyboard open (touch round, 7.10): the bottom bar and + get out of the way.
   On Android, with `interactive-widget=resizes-content` (in the viewport), the
   screen shrinks above the keyboard, and a floating bar would sit on it and
   cover what is being typed. As in apps. */
@media (pointer: coarse) {
    body:has(:is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select):focus) .bottom-nav,
    body:has(:is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select):focus) .fab {
        visibility: hidden;
    }
}
/* and the save bar on project editing drops into the place the bar vacated */
@media (pointer: coarse) {
    body:has(:is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select):focus) .project-save-bar {
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }
}

/* A sideways swipe on these belongs to the page (edit/delete, week paging),
   and scrolling up and down to the browser. When the browser knows this in
   advance it doesn't wait to check, and the swipe responds from the first touch
   (Matan, 11.10). */
.transaction-item, .cat-tx-row, .recurring-row, .week-card { touch-action: pan-y; }


/* ─── A soft transition between pages (Matan, 12.10) ──────────────────────
   Cross-document View Transitions: the old page fades and the new one rises,
   within about a quarter of a second. The bottom bar and the + stay in place
   (a name of their own: not part of the page's transition). Safari 18.2+ and
   Chrome; an old browser: as before, with no change. Swiping between months and
   the soft refresh happen within the same document and don't touch this. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 240ms cubic-bezier(0.4, 0, 0.2, 1) both sf-vt-out; }
::view-transition-new(root) { animation: var(--dur-slow) cubic-bezier(0.2, 0, 0, 1) both sf-vt-in; }
@keyframes sf-vt-out { to { opacity: 0; } }
@keyframes sf-vt-in { from { opacity: 0; transform: translateY(10px); } }
.bottom-nav { view-transition-name: sf-dock; }
.fab { view-transition-name: sf-fab; }
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
}


/* ─── Viewing a receipt inside the app (`js/receipt-viewer.js`, Matan 12.10) ─── */
.receipt-viewer {
    position: fixed; inset: 0; z-index: 400; background: rgba(8, 6, 3, 0.94);
    display: flex; align-items: center; justify-content: center;
    padding: calc(56px + env(safe-area-inset-top, 0px)) 12px calc(20px + env(safe-area-inset-bottom, 0px));
}
.receipt-viewer[hidden] { display: none; }
.receipt-viewer-stage { max-width: 100%; max-height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.receipt-viewer-stage img { display: block; max-width: 100%; max-height: calc(100dvh - 90px); border-radius: var(--radius-xs); cursor: zoom-in; }
.receipt-viewer.zoomed .receipt-viewer-stage { width: 100%; height: 100%; }
.receipt-viewer.zoomed .receipt-viewer-stage img { max-width: none; max-height: none; width: 220%; cursor: zoom-out; }
.receipt-viewer-close {
    position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); inset-inline-start: 12px;
    width: 40px; height: 40px; border-radius: 50%; border: 0;
    background: rgba(255, 255, 255, 0.14); color: #fff; font-size: var(--text-title); cursor: pointer;
}
.receipt-viewer-fail { color: #E7E0D2; text-align: center; }
.receipt-viewer-fail a { color: #E3BE55; }


/* "From the receipt": what the receipt scan filled in (Matan, 12.10) */
#modalOverlay .from-receipt { box-shadow: 0 0 0 2px var(--color-gold); border-radius: var(--radius-sm); animation: sf-receipt-pulse 1.2s ease-out 1; }
@keyframes sf-receipt-pulse { from { box-shadow: 0 0 0 6px rgba(166, 124, 0, 0.35); } }
.amount-input-wrap { position: relative; }
.from-receipt-tag {
    position: absolute; top: -18px; inset-inline-end: -6px; padding: 1px 8px; border-radius: var(--radius-pill);
    background: var(--color-gold-dim); color: var(--color-gold-text); font-size: var(--text-2xs); font-weight: 700;
}


/* "Got it" on an alert (Matan, 12.10) */
.alert-wrap { position: relative; }
.alert-wrap[hidden], .alerts-section[hidden] { display: none; }
.alert-wrap .alert-card { padding-inline-end: 44px; }
.alert-dismiss {
    position: absolute; top: 50%; inset-inline-end: 6px; translate: 0 -50%;
    width: 34px; height: 34px; border: 0; border-radius: 50%; background: none;
    color: currentColor; opacity: 0.55; font-size: var(--text-md); cursor: pointer;
}


/* "Project finished?" (Matan, 12.10) */
.project-quiet-banner {
    display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; padding: 12px 14px;
    /* A solid background, like `.project-archived-banner`: the bar sits on the
       edge of the dark hero, and a transparent background hid the text there
       (found in a screenshot, 12.10) */
    border-radius: var(--radius); background: var(--color-card); border: 1px solid var(--color-gold-border);
    box-shadow: var(--shadow-card); color: var(--color-text); font-size: var(--text-md);
}
.project-quiet-banner[hidden] { display: none; }
.project-quiet-actions { display: flex; gap: 8px; }


/* fixed versus variable (Matan, 12.10) */
/* Fixed / variable in the corners next to the ring (Matan, 13.10): small, no bar */
.donut-row { position: relative; }
/* Room for the two lines under the ring, and a line separating them from the
   category list (Matan, 13.10: "so there's a separation between them and the
   list") */
.donut-row.has-split { padding-bottom: 30px; margin-bottom: 6px; border-bottom: 1px solid var(--divider-subtle); }
.split-corner {
    position: absolute; bottom: 12px; right: 0; text-align: right;
    font-size: var(--text-2xs); color: var(--color-text-muted); line-height: 1.45;
}
.split-corner p { margin: 0; white-space: nowrap; }
.split-corner b { font-size: var(--text-2xs); font-weight: 700; color: var(--color-text-soft); }


/* a project pinned on home (Matan, 12.10) */
.pinned-project {
    display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 14px;
    border-radius: var(--radius); background: var(--color-card); box-shadow: var(--shadow-card);
    color: var(--color-text); text-decoration: none;
}
/* The card is a `div` since 23.11: the link covers it, the + sits above */
.pinned-project { position: relative; }
.pinned-project-link { color: inherit; text-decoration: none; }
.pinned-project-link::after { content: ""; position: absolute; inset: 0; }
.pinned-project-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--color-gold-dim); font-size: var(--text-lg); flex-shrink: 0; }
.pinned-project-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pinned-project-name { font-weight: 700; font-size: var(--text-body); }
.pinned-project-sub { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 2px; }
.pinned-project-sub b { color: var(--color-text); }
.pinned-project-sub .deficit, .pinned-project-sub .deficit b { color: var(--color-expense); }


/* "תשלום 3 מתוך 12" on the row (Matan, 12.10) */
.installment-tag { color: var(--color-gold-text); font-weight: 600; }
/* On a transaction's row it reads like "כל חודש" beside it (Matan, 1.12: "not
   under it and not in gold; an installment and a recurring one should look
   the same"): after a dot, in the row's own colour and weight. It is never cut
   (21.11: in a narrow row it read "תשלום 3 …"): when the name leaves it no
   room it drops whole to the next line, and the dot, which sits in the gap
   before it, is clipped away at the start of a line. A name too long for the
   row wraps instead of being shortened, in these rows only. */
.cat-tx-desc .installment-tag { display: table; margin-top: 3px; padding-inline: 0; color: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; }
@supports selector(:has(*)) {
    .cat-tx-desc:has(.installment-tag) {
        display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.95em; row-gap: 2px;
        white-space: normal; text-overflow: clip;
    }
    .cat-tx-desc .installment-tag { display: block; position: relative; margin-top: 0; white-space: nowrap; }
    .cat-tx-desc .installment-tag::before { content: "·"; position: absolute; inset-inline-end: 100%; width: 0.95em; text-align: center; }
}
.recurring-next .installment-tag { padding: 0; }
.empty-cta { margin-top: 14px; padding-inline: 22px; }
.switch-hint { display: block; margin-top: 2px; font-size: var(--text-sm); font-weight: 400; color: var(--color-text-muted); }
/* A row that opens something is at least 44px tall (audit, 22.11): the
   transaction rows in the week card and under a category were 33-35px, easy to
   miss with a finger. */
.cat-tx-row, .week-detail-list li.week-tx, .legend-item { min-height: 44px; }

.installments-group[hidden] { display: none; }
/* `hidden` inside the sheet really hides (Matan, 22.11): `.detail-row` and the
   edit buttons set a display of their own that outranked it, so the
   installments row showed while editing and on income, and "duplicate" on a
   recurring transaction. */
#modalOverlay [hidden] { display: none !important; }
.installments-group.is-locked .checkbox-label { cursor: default; opacity: 1; }
#modalOverlay .installments-group.is-locked .installments-hint { color: var(--color-gold-text); font-weight: 700; }
.installments-fields { display: flex; align-items: center; gap: 10px; flex: 1 1 100%; margin-top: 8px; }
.installments-fields[hidden] { display: none; }
.installments-count { width: 72px; text-align: center; font-weight: 700; }
/* Empty until a number is typed (Matan, 22.11): the hint is pale, not a value */
.installments-count::placeholder { font-weight: 400; color: var(--color-text-muted); opacity: 0.75; }
.installments-hint { flex: 1; min-width: 0; font-size: var(--text-md); color: var(--color-text-muted); text-wrap: balance; }


/* "what's new" (Matan, 12.10) */
.whats-new-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.whats-new-list li { display: flex; gap: 10px; align-items: flex-start; font-size: var(--text-body); line-height: 1.45; }
.whats-new-icon { flex-shrink: 0; width: 28px; text-align: center; }

/* "New: phone notifications" (Matan, 5.12; `js/push.js`) */
.push-news-bell {
    align-self: center; width: 52px; height: 52px; border-radius: 16px;
    display: grid; place-items: center;
    color: var(--color-gold-text); background: rgba(212, 175, 55, 0.16);
}
.push-news-bell svg { width: 26px; height: 26px; }
.push-news-title { text-align: center; font-size: var(--text-lg); }
.push-news-sub { margin: -6px 0 0; text-align: center; color: var(--color-text-muted); font-size: var(--text-body); line-height: 1.5; }
.push-news-hint { margin: 0; text-align: center; }

/* A family member joined (Matan, 12.10): in their colour (`owner-N`) */
.member-joined {
    display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 12px 14px;
    border-radius: var(--radius-sm); font-size: var(--text-body); font-weight: 600; background: var(--color-gold-dim);
}
.member-joined[hidden] { display: none; }
.member-joined-text { flex: 1; }
.member-joined-close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: inherit; opacity: 0.6; cursor: pointer; }

/* "My account" (Matan, 13.10): rows like in "recurring transactions": icon,
   name, what is recorded below, and an arrow. The whole row is the button; the
   editor opens under it. */
.acct-list { list-style: none; margin: 0; padding: 0; }
.acct-list > li { border-bottom: 1px solid var(--divider-subtle); }
.acct-list > li:last-child { border-bottom: none; }
#my-details .recurring-group-title:first-child { margin-top: 2px; }
.acct-row,
.acct-row.member-color-open {
    display: flex; align-items: center; gap: 12px; width: 100%;
    margin: 0; padding: 11px 0; min-height: 0; border: 0; border-radius: 0;
    background: none; color: inherit; font: inherit; text-align: right; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.acct-icon {
    width: 38px; height: 38px; border-radius: var(--radius-sm); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-input); color: var(--color-gold-text);
}
.acct-icon .ui-icon { width: 18px; height: 18px; }
.acct-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acct-label { font-weight: 600; font-size: var(--text-body); color: var(--color-text); }
.acct-value {
    margin-top: 1px; font-size: var(--text-xs); font-weight: 400; color: var(--color-text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acct-ltr { text-align: right; }
.acct-value-extra::before { content: " · "; }
.acct-chevron { display: flex; color: var(--color-text-muted); opacity: 0.6; }
.acct-chevron svg { width: 16px; height: 16px; }
.acct-note { margin: 0 0 10px; }
.acct-list .password-form { margin-top: 2px; }
.acct-list .password-form.visible, .acct-list .account-edit.visible { padding-bottom: 12px; }

/* "Save" disabled until something changes (Matan, 13.10): the same look as in
   the transaction sheet */
.btn-primary:disabled, .project-save-btn:disabled {
    background: var(--color-input); color: var(--color-text-muted);
    box-shadow: none; cursor: default; opacity: 1;
}


/* "September closed" (Matan, 13.10): on the first day of the month on the home page */
.recap-wrap { margin-bottom: 14px; }
.recap-card {
    padding: 16px 16px 14px; border-radius: var(--radius);
    background: var(--color-card); box-shadow: var(--shadow-card); color: var(--color-text);
}
.recap-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.recap-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--color-gold-dim); font-size: var(--text-title); flex-shrink: 0; }
.recap-title { margin: 0; font-weight: 700; font-size: 1rem; }
.recap-wrap .recap-close { top: 17px; translate: none; inset-inline-end: 8px; }
.recap-figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.recap-fig { text-align: center; padding: 8px 4px; border-radius: var(--radius-sm); background: var(--color-bg); }
.recap-fig-label { display: block; font-size: var(--text-2xs); color: var(--color-text-muted); }
.recap-fig-value { display: block; font-weight: 700; font-size: var(--text-body); margin-top: 2px; }
.recap-fig.good .recap-fig-value, .recap-lines .good { color: var(--color-income); font-weight: 700; }
.recap-fig.bad .recap-fig-value, .recap-lines .bad { color: var(--color-expense); font-weight: 700; }
.recap-lines { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: var(--text-md); }
.recap-lines li { display: flex; gap: 8px; align-items: baseline; }
.recap-line-icon { width: 20px; text-align: center; flex-shrink: 0; }
.recap-lines b { font-weight: 700; }

/* Signup: the problem under its field, while typing (Matan, 13.10; `login.js`) */
.field-error { margin: 5px 2px 0; font-size: var(--text-sm); font-weight: 500; color: var(--color-expense); }
.field-error[hidden] { display: none; }
.form-input[aria-invalid="true"] { border-color: var(--color-expense); }

/* importing from the card company (`/import`, Matan 31.10) */
.import-steps { margin: 0 0 16px; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; font-size: var(--text-body); color: var(--color-text-soft); }
.import-steps b { font-weight: 600; color: var(--color-text); }
.import-file-btn { cursor: pointer; padding: 12px 24px; font-size: var(--text-body); }
.import-file-btn.is-busy { opacity: 0.7; pointer-events: none; }
.import-privacy { margin-top: 14px; }
.import-sample-wrap { overflow-x: auto; margin: 12px 0 16px; border-radius: var(--radius-sm); border: var(--border-subtle); }
.import-sample { border-collapse: collapse; font-size: var(--text-xs); white-space: nowrap; }
.import-sample th, .import-sample td { padding: 6px 10px; text-align: start; border-bottom: 1px solid var(--divider-subtle); }
.import-sample th { font-weight: 700; background: var(--color-bg); }
.import-map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 380px) { .import-map-grid { grid-template-columns: 1fr; } }
.import-summary { margin: -6px 0 12px; font-size: var(--text-md); color: var(--color-text-muted); }
.import-owner { margin-bottom: 12px; }
.import-bulk { display: flex; gap: 8px; margin-bottom: 8px; }
.import-list { list-style: none; margin: 0; padding: 0; }
.import-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--divider-subtle); }
.import-row:last-child { border-bottom: none; }
.import-row.is-off .import-main { opacity: 0.5; }
.import-check { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--color-gold); }
.import-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.import-line { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.import-merchant { font-weight: 600; font-size: var(--text-body); overflow-wrap: anywhere; }
.import-amount { font-weight: 700; white-space: nowrap; color: var(--color-expense); }
.import-meta { display: flex; gap: 10px; align-items: center; }
.import-date { font-size: var(--text-sm); color: var(--color-text-muted); white-space: nowrap; min-width: 40px; }
.import-cat { padding: 7px 10px; font-size: var(--text-md); }
.import-row.needs-cat .import-cat { border-color: var(--color-expense); }
.import-note { margin: 0; font-size: var(--text-xs); color: var(--color-text-muted); }
.import-note.is-warn { color: var(--alert-warn-ink); }
.import-more { margin-top: 8px; }
.import-more .import-amount { color: var(--color-text-soft); }
.import-commit-bar {
    position: sticky; bottom: calc(var(--dock-height) + var(--dock-gap) + env(safe-area-inset-bottom, 0px) + 10px); z-index: 2;
    margin-top: 14px; display: flex;
}
.import-commit-bar .btn-sm { flex: 1; padding: 14px 18px; font-size: var(--text-body); box-shadow: var(--shadow-gold); }
.import-commit-bar .btn-sm:disabled { box-shadow: none; opacity: 0.6; }
.import-done { text-align: center; }
.import-done-icon {
    width: 52px; height: 52px; margin: 6px auto 12px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--color-gold-dim); color: var(--color-gold-text); font-size: var(--text-display); font-weight: 700;
}
.import-done .edit-actions { justify-content: center; }
.settings-import { margin: 4px 0 28px; text-align: center; font-size: var(--text-md); }
/* A small button and not a link (Matan, 31.10): "it doesn't look tappable". At
   the text's width, in light gold: quieter than the groups above it, and far
   enough from "sign out" */
.settings-import-link {
    display: inline-block; padding: 9px 18px; border-radius: var(--radius-sm);
    background: var(--color-gold-dim); border: 1px solid var(--color-gold-border);
    color: var(--color-gold-text); font-weight: 600; text-decoration: none;
    -webkit-tap-highlight-color: transparent; transition: transform 120ms ease-out;
}
.settings-import-link:active { transform: scale(0.97); }
.export-links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Restoring the default categories: at the bottom of management mode (Matan, 31.10) */
.restore-defaults { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--divider-subtle); text-align: center; }
.restore-defaults .field-hint { margin-top: 6px; }

/* The legend of the wizard's category step: three lines of text, no symbols
   (Matan, 31.10) */
.onboarding-legend { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--text-body); color: var(--color-text-soft); text-align: center; }

/* A new family with no transactions: two ways to start (Matan, 31.10) */
.hero-start-actions { display: flex; flex-direction: column; gap: 10px; margin: 18px auto 0; max-width: 320px; }
.hero-start-btn {
    display: block; padding: 13px 18px; border-radius: var(--radius-sm); text-align: center; text-decoration: none;
    font-size: var(--text-body); font-weight: 600; color: var(--hero-text);
    background: var(--hero-chip-bg); border: 1px solid var(--hero-chip-border);
    -webkit-tap-highlight-color: transparent; transition: transform 120ms ease-out;
}
.hero-start-btn.is-primary { background: var(--gradient-gold); border-color: transparent; color: #FFFFFF; box-shadow: var(--shadow-gold); }
.hero-start-btn:active { transform: scale(0.97); }
.hero-start-hint { margin-top: 10px; font-size: var(--text-xs); color: var(--hero-text-muted); }

/* A standing order in the import: make it a recurring transaction (Matan, 1.11) */
.import-recurring { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--color-gold-text); font-weight: 600; cursor: pointer; }
.import-recurring input { width: 16px; height: 16px; accent-color: var(--color-gold); flex-shrink: 0; }

/* The month summary: every number in its department's colour, as in the cards
   above it (Matan, 1.11) */
.recap-fig.income .recap-fig-value  { color: var(--color-income); }
.recap-fig.expense .recap-fig-value { color: var(--color-expense); }
.recap-fig.savings .recap-fig-value { color: var(--color-savings); }

/* A projected recurring transaction in a future month (Matan, 1.11): counted,
   but hasn't happened yet */
.cat-tx-row.is-projected { cursor: pointer; }
.cat-tx-row.is-projected .cat-tx-desc, .cat-tx-row.is-projected .cat-tx-amount { opacity: 0.75; }
.projected-tag {
    font-size: var(--text-2xs); font-weight: 600; padding: 2px 7px; border-radius: var(--radius-pill); white-space: nowrap;
    color: var(--color-gold-text); background: var(--color-gold-dim); border: 1px dashed var(--color-gold-border);
}

/* ── "2026 שלכם": the yearly summary (Matan, 1.11) ── */
.year-card {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
    padding: 16px; border: 0; border-radius: var(--radius); cursor: pointer;
    background: linear-gradient(150deg, var(--hero-bg) 0%, var(--hero-bg-2) 100%);
    color: var(--hero-text); box-shadow: var(--shadow-card);
}
.year-card-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.year-card-title { font-size: var(--text-title); font-weight: 700; color: var(--color-gold-bright); }
.year-card-sub { font-size: var(--text-md); color: var(--hero-text-muted); }
.year-card-arrow { font-size: var(--text-xl); color: var(--color-gold-bright); }
.months-year-card { margin: 16px 0 8px; }

.yr-overlay {
    position: fixed; inset: 0; z-index: 400; background: rgba(10, 8, 3, 0.55);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; transition: opacity var(--dur-medium);
}
/* `display: flex` beats `hidden`: without this the closed, transparent screen
   blocked every tap on the page */
.yr-overlay[hidden] { display: none; }
.yr-overlay.open { opacity: 1; }
.yr-sheet {
    position: relative; width: 100%; max-width: 560px; height: 94vh; height: 94dvh; overflow-y: auto;
    border-radius: 22px 22px 0 0; background: var(--color-bg);
    transform: translateY(40px); transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.yr-overlay.open .yr-sheet { transform: none; }
.yr-close {
    position: absolute; top: 14px; inset-inline-start: 14px; z-index: 1;
    width: 36px; height: 36px; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, 0.12); color: var(--hero-text); font-size: 1rem; cursor: pointer;
}
.yr-hero {
    padding: 34px 20px 26px; text-align: center; color: var(--hero-text);
    background: radial-gradient(120% 90% at 50% 0%, #3A2A0A 0%, var(--hero-bg) 70%);
}
.yr-kicker { margin: 0; font-size: var(--text-sm); letter-spacing: 0.04em; color: var(--hero-text-muted); }
.yr-title {
    margin: 6px 0 4px; font-size: 2.4rem; font-weight: 700;
    background: var(--gradient-gold-text); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.yr-sub { margin: 0; font-size: var(--text-md); color: var(--hero-text-muted); }
.yr-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.yr-loading { text-align: center; color: var(--color-text-muted); padding: 40px 0; }
/* The summary's cards (Matan, 29.11): the home page's "ספטמבר נסגר" card, one
   subject each. The three numbers sit in the hero, as on the month page. */
.yr-kpis { max-width: 420px; margin: 16px auto 0; }
.yr-kpis[hidden] { display: none; }
.yr-card .recap-figures, .yr-card .recap-lines { margin-bottom: 0; }
.yr-net { margin: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: var(--text-body); color: var(--color-text); }
.recap-figures + .yr-net { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(var(--ink-rgb), 0.07); }
.yr-net b { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.yr-net .good { color: var(--color-income); }
.yr-net .bad { color: var(--color-expense); }
/* The biggest categories, ranked: the bar is against the first, not against 100% */
.yr-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.yr-rank li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.yr-rank-n {
    grid-row: 1 / 3; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--color-gold-dim); color: var(--color-gold-text); font-weight: 700; font-size: var(--text-sm);
}
.yr-rank li:first-child .yr-rank-n { background: var(--gradient-gold); color: #fff; }
.yr-rank-name { font-weight: 600; font-size: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yr-rank-amount { font-weight: 700; font-size: var(--text-body); font-variant-numeric: tabular-nums; }
.yr-rank-amount small { display: inline-block; margin-inline-start: 8px; font-weight: 400; font-size: var(--text-sm); color: var(--color-text-muted); }
.yr-rank-bar { grid-column: 2 / 4; height: 8px; border-radius: 4px; background: rgba(var(--ink-rgb), 0.07); overflow: hidden; }
.yr-rank-bar i { display: block; height: 100%; border-radius: 4px; background: var(--gradient-gold); }
/* A category of the month's summary opens its expenses (Matan, 4.12): the row
   is a button laid out like the others, with a chevron that turns */
.yr-rank li.yr-rank-item { display: block; }
.yr-rank-btn { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center;
               width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: inherit; cursor: pointer; }
.yr-rank-chev { display: inline-block; width: 7px; height: 7px; margin-inline-start: 8px; border: solid var(--color-text-muted);
                border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); transition: transform .2s; }
.yr-rank-btn[aria-expanded="true"] .yr-rank-chev { transform: translateY(1px) rotate(-135deg); }
/* Under `.yr-rank`: `.yr-projects` (the same list look) comes later in the file */
/* In a soft box of its own (Matan, 4.12, option B): the open list ended right
   against the next category, and where one stopped and the other began wasn't
   clear */
.yr-rank .yr-rank-rows { margin: 10px 0 8px; margin-inline-start: 36px; padding: 2px 14px;
                         background: rgba(var(--ink-rgb), 0.04); border-radius: var(--radius-sm); }
.yr-rank .yr-rank-rows[hidden] { display: none; }
.yr-rank .yr-rank-rows li { padding: 7px 0; font-size: var(--text-sm); }
.yr-rank .yr-rank-rows li:first-child { padding-top: 9px; }
.yr-rank .yr-rank-rows li:last-child { padding-bottom: 9px; }
.yr-rank .yr-rank-rows span { font-weight: 500; }
.yr-rank .yr-rank-rows b { font-weight: 600; }
/* Who brought in and who spent: `.owner-N` gives each person's colour in both
   themes; the inner <i> paints it solid (the class's own background is a tint) */
/* In the month's summary each split is a link to the same split on the month's
   page (Matan, 1.12) */
.yr-who-link { display: block; color: inherit; text-decoration: none; border-radius: var(--radius-sm); }
.yr-who-link + .yr-who-link { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(var(--ink-rgb), 0.07); border-radius: 0; }
.yr-who-link:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 4px; }
.yr-who-more {
    margin-top: 12px; padding: 9px 10px; display: flex; justify-content: center; align-items: center; gap: 8px;
    border-radius: var(--radius-sm); background: var(--color-gold-dim); border: 1px solid var(--color-gold-border);
    font-size: var(--text-sm); font-weight: 700; color: var(--color-gold-text);
}
.yr-who-more::after {
    content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 0 2px 2px; transform: rotate(45deg);
}
/* The month against the one before: what is measured, both amounts with their
   months, and the difference in words (Matan, 1.12) */
.yr-cmp { list-style: none; margin: 0; padding: 0; }
.yr-cmp li { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.yr-cmp li + li { border-top: 1px solid rgba(var(--ink-rgb), 0.07); }
.yr-cmp .recap-line-icon { align-self: flex-start; margin-top: 2px; }
.yr-cmp .recap-line-icon.good, .yr-cmp-diff.good { color: var(--color-income); }
.yr-cmp .recap-line-icon.bad, .yr-cmp-diff.bad { color: var(--color-expense); }
.yr-cmp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--text-body); }
.yr-cmp-text > b { font-weight: 700; }
.yr-cmp-both b { font-weight: 600; color: var(--color-text-soft); }
.yr-cmp-both { font-size: var(--text-sm); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.yr-cmp-diff { font-weight: 700; font-size: var(--text-md); white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--color-text-muted); }
.yr-cmp-label { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid rgba(var(--ink-rgb), 0.12); font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.yr-who + .yr-who { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(var(--ink-rgb), 0.07); }
.yr-who-label { margin: 0 0 8px; font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.yr-who-bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; }
.yr-who-bar span { flex: 1 1 0; min-width: 4px; background: none; }
.yr-who-bar i, .yr-who-dot i { display: block; width: 100%; height: 100%; background: currentColor; }
.yr-who-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.yr-who-list li { display: flex; align-items: center; gap: 8px; font-size: var(--text-body); }
.yr-who-dot { width: 10px; height: 10px; border-radius: 50%; overflow: hidden; flex-shrink: 0; background: none; }
.yr-who-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yr-who-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.yr-who-amount small { display: inline-block; margin-inline-start: 8px; font-weight: 400; font-size: var(--text-sm); color: var(--color-text-muted); }
/* Against last year: the sentence, and its number at the end of the row */
.yr-vs { gap: 11px; font-size: var(--text-body); }
.yr-vs li { align-items: center; }
.yr-vs-text { flex: 1; min-width: 0; }
.yr-vs-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The records: the kind in its colour and the question above, the answer below */
.yr-peaks, .yr-projects { list-style: none; margin: 0; padding: 0; }
.yr-peak { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline; padding: 11px 0; }
.yr-peak:first-child, .yr-projects li:first-child { padding-top: 0; }
.yr-peak:last-child, .yr-projects li:last-child { padding-bottom: 0; }
.yr-peak + .yr-peak, .yr-projects li + li { border-top: 1px solid rgba(var(--ink-rgb), 0.07); }
.yr-peak-kind { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--color-text-muted); }
.yr-peak-kind i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--color-text); }
.yr-peak-kind b { font-weight: 600; color: var(--color-text); }
.yr-peak-what { font-weight: 600; font-size: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yr-peak-amount { font-weight: 700; font-size: var(--text-body); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.yr-peak-hint { grid-column: 1 / -1; font-size: var(--text-2xs); color: var(--color-text-muted); }
.yr-peak.inc .yr-peak-kind i { background: var(--color-income); }
.yr-peak.inc .yr-peak-kind b, .yr-peak.inc .yr-peak-amount { color: var(--color-income); }
.yr-peak.exp .yr-peak-kind i { background: var(--color-expense); }
.yr-peak.exp .yr-peak-kind b, .yr-peak.exp .yr-peak-amount { color: var(--color-expense); }
.yr-peak.sav .yr-peak-kind i { background: var(--color-savings); }
.yr-peak.sav .yr-peak-kind b, .yr-peak.sav .yr-peak-amount { color: var(--color-savings); }
.yr-projects li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; font-size: var(--text-body); color: var(--color-text); }
.yr-projects span { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yr-projects b { font-variant-numeric: tabular-nums; }
.yr-biggest small { margin-inline-start: 4px; font-size: var(--text-2xs); font-weight: 500; color: var(--color-text-soft); opacity: 0.8; }
/* The button on "נובמבר נסגר" that opens the month's summary (Matan, 1.12,
   option ג of four). Only it opens the summary, not the whole card. */
.recap-more {
    width: 100%; min-height: 44px; font-family: inherit; cursor: pointer;
    margin: 2px 0; padding: 10px; display: flex; justify-content: center; align-items: center; gap: 8px;
    border-radius: var(--radius-sm); background: var(--color-gold-dim); border: 1px solid var(--color-gold-border);
    font-size: var(--text-md); font-weight: 700; color: var(--color-gold-text);
}
/* An arrow pointing on, to the left, drawn so its direction doesn't depend on the font */
.recap-more::after {
    content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 0 2px 2px;
    transform: rotate(45deg);
}
@media (hover: hover) { .recap-more:hover { border-color: var(--color-gold); } }
.recap-more:active { opacity: 0.75; }
.recap-more:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.yr-done {
    margin-top: 4px; padding: 14px; border: 0; border-radius: var(--radius-sm); cursor: pointer;
    background: var(--color-text); color: var(--color-bg); font-size: 1rem; font-weight: 700;
}
/* On the home page: spacing from the next card, and a light ✕ at the edge: the
   arrow moves inwards so it doesn't collide with it */
.year-card-wrap { margin-bottom: 14px; }
.year-card-wrap .year-card { padding-inline-end: 46px; }
.year-card-wrap .alert-dismiss { color: var(--hero-text); opacity: 0.6; }

/* Focus rings that were missing (design pass, 11.11): the search field drew
   none, the project's track checkboxes hide the real input, and the import's
   file input is visually hidden behind its label */
.search-bar:focus-within { outline: 2px solid var(--color-gold-text); outline-offset: 2px; }
.checkbox-input:focus-visible + .checkbox-custom { outline: 2px solid var(--color-gold-text); outline-offset: 2px; }
.import-file-btn:has(+ input:focus-visible) { outline: 2px solid var(--color-gold-text); outline-offset: 2px; }

/* An onboarding step's title takes focus when the step opens (`onboarding.js`):
   it is where reading starts, not a control, so no ring */
.auth-form-title:focus { outline: none; }

/* "By family member" on the month page: a row per member instead of a bar chart
   (design pass, 11.11). Name, a bar in their colour, the amount. */
.member-bars { list-style: none; margin: 6px 0 2px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.member-bar { display: grid; grid-template-columns: 4.75rem 1fr auto 14px; align-items: center; gap: 12px; }
.member-bar.clickable { cursor: pointer; }
.member-bars > .legend-item-wrap { border-bottom: none; }
.member-bars .cat-tx-list { margin-top: 10px; }
.member-bar-name {
    font-size: var(--text-md); font-weight: 600; color: var(--color-text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.member-bar-track { height: 10px; border-radius: var(--radius-pill); background: rgba(var(--ink-rgb), 0.07); overflow: hidden; }
.member-bar-track > span { display: block; height: 100%; border-radius: inherit; }
.member-bar-amount {
    font-size: var(--text-md); font-weight: 700; color: var(--color-text);
    font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate;
}

/* "Pinned to home" on the project page: the pin filled in gold (11.11) */
.project-pin-btn[aria-pressed="true"] { background: var(--color-gold-bright); border-color: var(--color-gold-bright); color: var(--hero-bg); }

/* Line icons where decorative emoji were (design pass, 11.11) */
.recap-icon { color: var(--color-gold-text); }
.recap-line-icon { display: inline-flex; justify-content: center; }
.recap-line-icon.good { color: var(--color-income); }
.recap-line-icon.bad  { color: var(--color-expense); }
.empty-row-icon { color: var(--color-gold-text); display: inline-flex; }
.onboarding-choice-icon { color: var(--color-gold-text); display: inline-flex; }
.onboarding-choice-icon .ui-icon { stroke-width: 1.8; }
.project-tile-tag .ui-icon { width: 0.95em; height: 0.95em; }
.whats-new-icon { color: var(--color-gold-text); display: inline-flex; justify-content: center; padding-top: 2px; }

/* A soft fade above the bottom bar (design pass, 11.11): amounts showed in the
   gap beside the +, and a whole row under the bar. The content now melts into
   the page colour before it reaches the bar. Under the bar and the +, over the
   content, and it never takes a tap. Only on pages that have the bar. */
body:has(> .bottom-nav)::after {
    content: '';
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(var(--dock-height) + var(--dock-gap) + env(safe-area-inset-bottom, 0px) + 28px);
    /* Clear for the top 28px, then solid from the bar's top edge down */
    background: linear-gradient(to bottom, transparent, var(--color-bg) 28px);
    pointer-events: none;
    z-index: calc(var(--z-dock) - 1);
}

/* ─── Behind the clock and battery, second try (design pass, 11.11) ───
   iOS 26 ignores theme-color and tints the status bar area from the page's
   background colour, ours is cream, so a faded cream-grey band sat over the dark
   header. The first try (10.11) laid a fixed strip there and looked pasted on;
   Matan reverted it. This time no element is added: on pages with the dark
   header, the page's own colour is the header's dark, and the cream is a layer
   that starts 120px down, under the header, which always covers that much. So
   the dark band simply continues up behind the clock. The canvas (html) stays
   cream, which is what a pull past the bottom shows.
   An experiment only an iPhone can confirm: if it looks wrong, revert this
   commit. */
html:has(> body > .page-hero) { background: var(--color-bg); }
body:has(> .page-hero) {
    background-color: var(--hero-bg-2);
    background-image: linear-gradient(var(--color-bg), var(--color-bg));
    background-position: 0 120px;
    /* The cream ends where the page ends: at full size and 120px down, the last
       120px of the page showed dark under the last card (Matan's iPhone, 11.11) */
    background-size: 100% calc(100% - 120px);
    background-repeat: no-repeat;
}
/* Once the dark header has scrolled away, the page's colour is cream again, so
   iOS stops tinting the clock area brown over cream cards (Matan, 11.11) */
html.past-hero body:has(> .page-hero) { background-color: var(--color-bg); }

/* ─── Buttons: three heights (design pass, stage 8, 11.11) ───────────
   Measured in the harness: the same .btn-sm came out 32, 36, 42 and 44px tall,
   the two "בואו נתחיל" buttons 46 and 51, the project's save 47. Now every
   button is one of three heights: small (in a row of controls), medium (a
   button of its own inside a card) and large (the screen's main action). Only
   the height is set here; colours and wording stay with each button. */
:root {
    --btn-h-sm: 36px;
    --btn-h-md: 44px;
    --btn-h-lg: 54px;
}
:where(.btn-sm) { min-height: var(--btn-h-sm); }    /* zero weight: a button that needs 44 ("לכל עסקאות החודש") keeps it */
.confirm-actions .btn-sm,
.logout-btn,
.project-save-btn,
.project-save-cancel,
.import-file-btn,
.duplicate-tx-btn,
.delete-tx-btn,
.install-bar-go,
.yr-done {
    min-height: var(--btn-h-md);
    padding-block: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.logout-btn, .duplicate-tx-btn, .delete-tx-btn, .yr-done { display: flex; }
.hero-start-btn {
    min-height: var(--btn-h-lg);
    padding-block: 0;
    display: flex; align-items: center; justify-content: center;
}
:where(.empty-row-add) { min-height: var(--btn-h-sm); }

/* ─── Tags: one size (design pass, stage 8, 11.11) ───────────────────
   The small labels that only inform (whose, a project, "צפוי", a payment
   number, me, manager…) came in four heights (16-23px), text from 10.4 to
   12.5px and weights from 400 to 700. Now one size; each keeps its colours. */
.owner-pill, .owner-pill-sm, .project-tag, .projected-tag, .installment-tag,
.me-badge, .manager-badge, .hero-badge, .project-tile-tag, .from-receipt-tag,
.week-fixed-tag, .all-tx-count, .current-month-badge, .week-cmp {
    font-size: var(--text-2xs);
    font-weight: 600;
    line-height: 1.4;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

/* ─── Chips: one size (design pass, stage 8, 11.11) ──────────────────
   The tappable chips (filter by type and category, sort, range) all build on
   .date-chip, and each variant set its own height (34, 36, ~30), padding and
   text. Now one: 36px, the same padding and text; a 44px tap area stays
   where it was given (`.range-chip::before`). Chosen: also bold, so the state
   isn't carried by colour alone. The sheet's own date row is styled by
   #modalOverlay and isn't touched. */
.tx-type-chip, .tx-cat-chip, .tx-sort-chip, .range-chip {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 36px;
    padding: 0 14px;
    font-size: var(--text-sm);
}
.tx-type-chip.active, .tx-cat-chip.active, .tx-sort-chip.active, .range-chip.active { font-weight: 700; }

/* A sheet fitted above the iPhone keyboard (`kb-fit`): the page behind it is
   not drawn at all. iOS shows the page in the strip the keyboard's bar floats
   over, where a fixed sheet can't reach, and for a second the home page
   showed under Save (Matan, 22.11: "I don't want it to happen at all"). With
   the page hidden that strip is the sheet's own colour. */
html.sheet-typing, html.sheet-typing body { background: var(--color-bg-elevated) !important; }
html.small-sheet-typing, html.small-sheet-typing body { background: var(--color-card) !important; }
html.sheet-typing body > :not(#modalOverlay):not(.toast):not(.confirm-overlay),
html.small-sheet-typing body > :not(.color-sheet):not(.toast) { visibility: hidden !important; }

/* The holder of each page's own scripts and dialogs (base.html): not a box */
.page-extras { display: contents; }

/* A savings project's bar at the top of its page: green, it fills as money goes in */
.balance-bar-fill.saving { background: var(--color-income-light); }

/* "צפוי השבוע" on the home page (Matan, 23–24.11): three parts (in, out, to
   savings), each a short timeline: a line down the side, a dot per date */
.upcoming-card .chart-title { margin: 0 0 2px; }
.upcoming-part { margin-top: 12px; }
.upcoming-part-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 2px; font-size: var(--text-xs); color: var(--color-text-muted); }
/* `ltr`: the + of an income stays in front of the amount */
.upcoming-part-total { font-size: var(--text-md); font-variant-numeric: tabular-nums; color: var(--color-text); direction: ltr; unicode-bidi: isolate; }
.upcoming-part-total.is-income { color: var(--color-income); }
.upcoming-part-total.is-expense { color: var(--color-expense); }
.upcoming-part-total.is-savings { color: var(--color-gold-text); }
.upcoming-list { position: relative; list-style: none; margin: 0; padding: 0; padding-inline-start: 18px; }
.upcoming-list::before { content: ""; position: absolute; inset-block: 14px; inset-inline-start: 4px; width: 2px; background: var(--divider-subtle); }
.upcoming-row {
    position: relative; display: flex; align-items: baseline; gap: 8px; min-height: 40px; padding: 8px 0;
    color: var(--color-text); text-decoration: none; font-size: var(--text-md);
}
.upcoming-row::before {
    content: ""; position: absolute; inset-inline-start: -18px; top: 15px; width: 10px; height: 10px; box-sizing: border-box;
    border-radius: 50%; background: var(--color-card); border: 2px solid var(--color-text-muted);
}
.upcoming-row.is-soon::before { background: var(--color-gold); border-color: var(--color-gold); }
.upcoming-day { flex: none; width: 34px; font-size: var(--text-xs); color: var(--color-text-muted); }
.upcoming-row.is-soon .upcoming-day { color: var(--color-gold-text); font-weight: 700; }
.upcoming-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upcoming-amount { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Pages that load their own data (the frontend/backend split) ──
   Such a page keeps its optional pieces in the HTML, hidden, until the data
   says which to show. A class that sets `display` beats the `hidden`
   attribute (the "new project" button stayed on screen for a family with no
   projects), so inside a view, and for the pieces a view keeps in the hero,
   `hidden` is made to hold. */
[data-view-url] [hidden],
.projects-new-btn[hidden], .projects-summary[hidden], .projects-count[hidden] { display: none !important; }
/* The project page keeps its hero's pieces too (`project_detail_view.html`) */
.page-hero .stats-nav-btn[hidden], .project-net[hidden], .hero-totals[hidden], .hero-bar[hidden],
.month-net[hidden], .kpi-chips[hidden] { display: none !important; }
/* And the home page's two heroes, of which the data shows one (`index_view.html`) */
.hero-balance[hidden] { display: none !important; }

/* "עוד צפוי החודש" on the month page (Matan, 1.12): the "צפוי השבוע" card of
   home, with the month's own rows; a line says the amounts are not counted yet */
.month-ahead-note { margin: 0 0 4px; font-size: var(--text-xs); color: var(--color-text-muted); }
.month-ahead-card .cat-tx-list { margin-top: 2px; }
/* Every row here is still to come, whether it is already entered or a charge
   of a series not made yet, and the card's title says so (Matan, 1.12: "some
   are dark and some light, and I didn't understand the difference"). So no
   "צפוי" tag on each and no dimming: they all look the same. */
.month-ahead-card .projected-tag { display: none; }
.month-ahead-card .cat-tx-row.is-projected .cat-tx-desc,
.month-ahead-card .cat-tx-row.is-projected .cat-tx-amount { opacity: 1; }


/* "Whose card?" on the import page waits hidden until its data says whether
   the family has the question (the frontend/backend split, step 3): `hidden`
   holds over the form-group's display */
.import-owner[hidden] { display: none !important; }
