/* Stats detail cards (uifixes). Loaded last.
   1. A category row opens into an inline detail card: the row's own surface grows outward around its icon, name and
      amount (which do not move), then the panel reveals subcategories, the latest records and the existing actions.
   2. An open week becomes a card with a seven-day strip; a day shows its records right under the strip.
   3. A month bar in Category by month previews its records inside the active card.
   Plain surfaces, 1px hairlines and the 20px card radius, like every other Stats card. */

/* 1. Category row -> detail card */
html[data-theme] #app .share-row{position:relative;margin-inline:0;padding-inline:0;border-radius:0;background:transparent;box-shadow:inset 0 0 0 1px transparent;transition:margin var(--motion-move) var(--motion-ease),padding var(--motion-move) var(--motion-ease),border-radius var(--motion-move) var(--motion-ease),background-color var(--motion-move) var(--motion-ease),box-shadow var(--motion-move) var(--motion-ease)}
html[data-theme] #app .share-row.is-open{margin:6px -12px;padding-inline:12px;border-radius:var(--radius-card);background:var(--subtle);box-shadow:inset 0 0 0 1px var(--border)}
html[data-theme] #app .share-row.is-open,html[data-theme] #app .share-row.is-open+.share-row{border-top-color:transparent}
#app[data-route=stats] .sov-analyzer .share-row.is-open{border-bottom-color:transparent}
html[data-theme] #app .share-row.is-open .share-row-toggle:focus-visible{outline-offset:-2px;border-radius:var(--radius-card)}
html[data-theme] #app .share-panel .sp-label{margin:4px 0 4px;color:var(--muted);font-size:var(--text-xs);font-weight:600;letter-spacing:.02em}
html[data-theme] #app .share-panel .sp-subs{padding-left:0;margin-bottom:10px}
html[data-theme] #app .sp-recent{display:grid;margin:0 0 10px;padding:0;list-style:none}
html[data-theme] #app .sp-recent>li+li{border-top:1px solid var(--divider)}
html[data-theme] #app .sp-tx{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;width:100%;min-height:48px;margin:0;padding:6px 0;border:0;background:none;color:var(--text);font:inherit;text-align:left;cursor:pointer}
html[data-theme] #app .sp-tx:focus-visible{outline:2px solid var(--reference-blue);outline-offset:2px;border-radius:8px}
html[data-theme] #app .sp-tx-text{display:grid;min-width:0}
html[data-theme] #app .sp-tx-text>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--text-sm);font-weight:500}
html[data-theme] #app .sp-tx-text>small{color:var(--muted);font-size:var(--text-xs)}
html[data-theme] #app .sp-tx-amount{font-size:var(--text-sm);font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}
html[data-theme] #app .share-row.is-open .sp-actions{border-top:1px solid var(--divider);padding-top:6px}
/* Contents fade up a beat after the surface starts to grow, and leave first on close. */
html[data-theme] #app .share-panel>.sp-inner>*{opacity:0;transform:translateY(-4px);transition:opacity var(--motion-exit) var(--motion-ease),transform var(--motion-exit) var(--motion-ease)}
html[data-theme] #app .share-row.is-open .share-panel>.sp-inner>*{opacity:1;transform:none;transition:opacity var(--motion-enter) var(--motion-ease) 80ms,transform var(--motion-enter) var(--motion-ease) 80ms}
html[data-theme] #app .share-row.sr-instant,html[data-theme] #app .share-row.sr-instant .share-panel>.sp-inner>*{transition:none}

/* 2. Week row -> week card */
#app[data-route=stats] .stats-weeks .week{border-radius:0;transition:margin var(--motion-move) var(--motion-ease),padding var(--motion-move) var(--motion-ease),border-radius var(--motion-move) var(--motion-ease),background-color var(--motion-move) var(--motion-ease),box-shadow var(--motion-move) var(--motion-ease)}
#app[data-route=stats] .stats-weeks .week[open]:not(:has(>summary[aria-expanded=false])){margin:8px -12px;padding-inline:12px;border-radius:var(--radius-card);background:var(--subtle);box-shadow:inset 0 0 0 1px var(--border)}
#app[data-route=stats] .stats-weeks .week[open]:not(:has(>summary[aria-expanded=false]))+.week{border-top-color:transparent}
#app[data-route=stats] .week-explorer .week-selection-readout{min-height:0;padding:10px 0 6px}
#app[data-route=stats] .week-explorer .week-selection-readout>strong{font-size:var(--text-lg)}
#app[data-route=stats] .week-explorer[data-week-selected=""] .week-selection-readout>[data-week-copy=label]{color:var(--muted);font-weight:500}
.week-daily-graph{grid-template-columns:repeat(var(--week-days,7),minmax(0,1fr))}
#app .week-day{min-height:156px}
#app .week-day.is-empty .week-day-track{opacity:.35}
.week-day-empty{font-size:var(--text-2xs);line-height:1.2;color:var(--muted)}
.week-day-preview{display:grid;gap:0;margin:4px 0 0;padding:0;list-style:none}
.week-day-preview>li+li{border-top:1px solid var(--divider)}
.week-day-heading{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin:8px 0 2px;font-size:var(--text-sm);font-weight:600;font-variant-numeric:tabular-nums}
.week-day-heading small{color:var(--muted);font-size:var(--text-xs);font-weight:500}
.week-day-actions{display:flex;flex-wrap:wrap;gap:4px 16px;align-items:center}
.week-day-actions>*{min-height:44px}
.week-day-note{margin:8px 0 0;color:var(--muted);font-size:var(--text-sm)}

/* Shared record row used by the week and month previews. */
.detail-tx{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;width:100%;min-height:48px;margin:0;padding:6px 0;border:0;background:none;color:var(--text);font:inherit;text-align:left;cursor:pointer}
.detail-tx:focus-visible{outline:2px solid var(--reference-blue);outline-offset:2px;border-radius:8px}
.detail-tx-text{display:grid;min-width:0}
.detail-tx-text>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--text-sm);font-weight:500}
.detail-tx-text>small{color:var(--muted);font-size:var(--text-xs)}
.detail-tx-amount{font-size:var(--text-sm);font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}

/* 3. Month bar -> in-card preview. The active card grows to fit its preview; the deck follows. */
.cc-deck{height:var(--cc-deck-height,300px);transition:height var(--motion-move) var(--motion-ease)}
.cc-card{height:var(--cc-card-height,272px)}
.cc-card.has-preview[data-pos="0"]{height:auto;min-height:272px}
/* With a day picked, the week's own add button gives way to the day's. */
#app[data-route=stats] .stats-weeks .week:has([data-week-explorer]:not([data-week-selected=""])) .text-button[data-action=add-date]:not([data-week-explorer] *){display:none}
.cc-card-preview{margin:4px 0 0;padding-top:8px;border-top:1px solid var(--divider)}
.cc-card-preview[hidden]{display:none}
.cc-card-preview h3{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin:0 0 2px;font-size:var(--text-sm);font-variant-numeric:tabular-nums}
.cc-card-preview h3 small{color:var(--muted);font-size:var(--text-xs);font-weight:500}
.cc-card-preview ul{display:grid;margin:0;padding:0;list-style:none}
.cc-card-preview li+li{border-top:1px solid var(--divider)}
.cc-card-preview .text-button{min-height:44px}
.cc-card-preview>p{margin:6px 0;color:var(--muted);font-size:var(--text-sm)}
.cc-card .cc-col[aria-pressed=true] .cc-bar{stroke:var(--text);stroke-width:1.5}

@media (prefers-reduced-motion:reduce){
 html[data-theme] #app .share-row,html[data-theme] #app .share-panel>.sp-inner>*,#app[data-route=stats] .stats-weeks .week,.cc-deck{transition:none}
}

/* 4. Share image: style and number choices sit around the live preview of the exact image. */
.spend-report .report-choice{display:flex;width:100%;margin:0 0 12px}
.spend-report .report-choice>button{flex:1;min-width:0;min-height:44px}
.spend-report .spend-report-frame+.report-choice{margin-top:16px}
.spend-report .report-mode-note{margin:0 0 4px;font-size:var(--text-xs)}
.spend-report .spend-report-frame{transition:background-color var(--motion-enter) var(--motion-ease)}
.spend-report[data-preset=clean] .spend-report-frame{background:#f7f6f1;box-shadow:inset 0 0 0 1px var(--border)}

/* ---- Stats review fixes (2026-11-06) ---- */
/* Palette: one recorded-spending blue, category colours without green or red, amber for change, green only for on track. */
#app[data-route=stats]{--stats-change:#9a5b00;--stats-change-soft:#fbecd2}
#app[data-route=stats] .stats-studio .stats-analyzer.sov-analyzer{--sov-food:#c39a2e;--sov-shop:#c2705a}
html[data-theme=dark] #app[data-route=stats],html[data-theme=grey-glass] #app[data-route=stats]{--stats-change:#f0b866;--stats-change-soft:color-mix(in srgb,#f0b866 18%,var(--surface))}
html:is([data-theme=dark],[data-theme=grey-glass]) #app[data-route=stats] .stats-studio .stats-analyzer.sov-analyzer{--sov-food:#e0bd62;--sov-shop:#e39a86}
#app[data-route=stats] .sov-meter-fill{fill:var(--stats-recorded)}
#app[data-route=stats] .sov-meter-fill[data-over-budget=true]{fill:var(--error)}
#app[data-route=stats] .cc{--cc-blue:var(--stats-recorded)}
#app[data-route=stats] .report-limit-list progress::-webkit-progress-value{background:var(--stats-recorded)}
#app[data-route=stats] .report-limit-list progress::-moz-progress-bar{background:var(--stats-recorded)}
#app[data-route=stats] .cc-pill[data-kind=up]{background:var(--stats-change-soft);color:var(--stats-change)}
html[data-theme] #app[data-route=stats] .sp-change[data-tone=up]{color:var(--stats-change)}
/* The observation tile reads in every theme: a light accent tint over the surface, never a fixed cream. */
#app[data-route=stats] .sov-insight-icon{background:color-mix(in srgb,var(--decorative,#ffbb6a) 22%,var(--surface));color:var(--text)}

/* Type: nothing under 12 px. */
#app[data-route=stats] .stats-comparison-summary{display:block;font-size:var(--text-xs);color:var(--muted);line-height:1.5}
#app[data-route=stats] .stats-comparison-summary>summary{cursor:pointer;align-content:center;min-height:44px;color:var(--link,var(--text))}
#app[data-route=stats] .stats-comparison-summary>div{padding:0 0 8px 16px}
#app[data-route=stats] .stats-comparison-summary :is(p,dl){margin:0 0 6px}
#app[data-route=stats] .stats-comparison-summary dl{display:flex;flex-wrap:wrap;gap:6px 18px}
#app[data-route=stats] .stats-comparison-summary dd{margin:0;color:var(--text);font-variant-numeric:tabular-nums}
html[data-theme] #app .share-panel .sp-change small,#app[data-route=stats] .glance-chart text{font-size:12px}

/* Touch: every Stats switch and chip is 44 px tall. */
html[data-theme] #app[data-route=stats] .stats-studio :is(.segmented,.stats-category-period,.group-chart-switch,.dtd-compare)>button{min-height:44px}

/* One card system: plain surface, 1 px hairline, 20 px radius; rows inside, not cards inside cards. */
#app[data-route=stats] .sov-allowance{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card)}
#app[data-route=stats] :is(.sov-fold,.stats-group-chart,.stats-ledger,.stats-glance-fold){border-radius:var(--radius-card)}
#app[data-route=stats] .sov-group{display:grid;min-width:0;border:1px solid var(--border);border-radius:var(--radius-card);background:var(--surface);overflow:hidden}
#app[data-route=stats] .sov-group>.sov-fold{border:0;border-radius:0;background:none}
#app[data-route=stats] .sov-group>.sov-fold+.sov-fold{border-top:1px solid var(--divider)}
#app[data-route=stats] .report-insights .report-insight-track{display:grid;gap:0}
#app[data-route=stats] .report-insights .report-insight-track>.report-insight{border:0;border-radius:0;background:none;box-shadow:none;padding:14px 0}
#app[data-route=stats] .report-insights .report-insight-track>.report-insight+.report-insight{border-top:1px solid var(--divider)}
#app[data-route=stats] .stats-studio .card>h2,#app[data-route=stats] .stats-studio :is(.section-heading,.report-history-head) h2{font-size:1.125rem;line-height:1.35}
#app[data-route=stats] .sov-period:not(:has(>span)){justify-content:flex-end}
/* The deck's navigation already counts the cards. */
#app[data-route=stats] .cc-card-head small{display:none}
/* Month review: one button at the end of Overview and Details. */
#app[data-route=stats] .stats-studio[data-stats-view=details]>.stats-month-review{display:block}
#app[data-route=stats] .stats-month-review .button{border-radius:var(--radius-card)}
/* Weeks key: a swatch for the bar, plain words for the amount. */
#app[data-route=stats] .stats-weeks .week-chart-key{display:flex;flex-wrap:wrap;gap:4px 16px}
#app[data-route=stats] .stats-weeks .week-chart-key>span{display:inline-flex;align-items:center;gap:6px}
#app[data-route=stats] .stats-weeks .week-key-bar{display:inline-block;width:14px;height:4px;border-radius:2px;background:var(--stats-recorded)}
/* Week rows show their chevron in the column kept for it, so a closed week reads as tappable. */
#app[data-route=stats] .stats-weeks .week>summary>.disclosure-chevron{grid-column:3;grid-row:1;align-self:start;margin-top:2px;justify-self:end;display:grid;place-items:center;width:20px;height:20px;color:var(--muted)}

/* ---- Experience pass 2 (2026-11-06) ---- */
/* Repeat payments: one line per payment, amount on the right. */
#app[data-route=stats] .report-fixed-rows{display:grid;margin:8px 0 12px;padding:0;list-style:none}
#app[data-route=stats] .report-fixed-rows>li{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;min-height:56px;padding:8px 0}
#app[data-route=stats] .report-fixed-rows>li+li{border-top:1px solid var(--divider)}
#app[data-route=stats] .report-fixed-name{display:grid;gap:2px;min-width:0}
#app[data-route=stats] .report-fixed-name>strong{font-size:var(--text-sm);font-weight:600;overflow-wrap:anywhere}
#app[data-route=stats] .report-fixed-name>small{color:var(--muted);font-size:var(--text-xs);line-height:1.45}
#app[data-route=stats] .report-fixed-amount{display:grid;justify-items:end;gap:0;font-size:var(--text-sm);font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}
#app[data-route=stats] .report-fixed-amount>.text-button{min-height:36px;padding:0;font-size:var(--text-xs);font-weight:500}
#app[data-route=stats] .report-fixed-amount>.text-button::after{content:"";position:absolute;inset:-4px -8px}
#app[data-route=stats] .report-fixed-amount>.text-button{position:relative}
/* Observations: a labelled Hide menu instead of a faint ellipsis. */
#app[data-route=stats] .report-insight-more>summary{min-width:0;min-height:44px;padding:0 4px;font-size:var(--text-xs);font-weight:500;letter-spacing:0;color:var(--muted)}
#app[data-route=stats] .report-insight-more[open]{display:flex;flex-wrap:wrap;gap:8px;padding-top:4px}
#app[data-route=stats] .report-insight-more[open]>summary{flex-basis:100%;justify-content:flex-start}
/* The category bar reads at a glance; the rows below take the taps. Pie keeps its own targets. */
#app[data-route=stats] [data-group-mode=bar] .group-chart-shape{pointer-events:none;cursor:default}
/* The search list sits right under the categories on Overview. */
#app[data-route=stats] .sov-analyzer .stats-ledger{margin-top:12px;border:1px solid var(--border);border-radius:var(--radius-card);background:var(--surface);padding:0 16px}
#app[data-route=stats] .sov-analyzer .stats-ledger>summary{min-height:56px}
/* Aesthetic polish: an even rhythm between Overview blocks and calmer secondary text. */
#app[data-route=stats] .stats-studio[data-overview=true]{row-gap:16px}
#app[data-route=stats] .sov-balance .sov-total{letter-spacing:-.02em}
#app[data-route=stats] .sov-allowance .sov-allowance-value{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
#app[data-route=stats] .report-insights .report-insight-figure{font-variant-numeric:tabular-nums}
/* The week chevron is drawn in CSS: two strokes, turned by the shared open/closed rotation. */
#app[data-route=stats] .stats-weeks .week-chevron::before{content:"";width:7px;height:7px;margin-top:-4px;border-right:1.75px solid currentColor;border-bottom:1.75px solid currentColor;transform:rotate(45deg)}
/* What stood out uses the same plain card as its neighbours; every disclosure row is a 44 px target. */
#app[data-route=stats] .stats-studio .report-insights{border:1px solid var(--border);border-radius:var(--radius-card);background:var(--surface);box-shadow:none}
#app[data-route=stats] .stats-studio details>summary{min-height:44px}

/* ---- Pass 3 (2026-11-06) ---- */
/* Coverage and Month / Year share one row. */
#app[data-route=stats] .sov-scope-row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0}
#app[data-route=stats] .sov-scope-row>.stats-recorded-scope{flex:1 1 auto;min-width:0;margin:0}
#app[data-route=stats] .sov-scope-row>.sov-period{flex:none;margin:0}
/* Open week: the row above already names the week and its total, so the readout only speaks when a day is picked,
   and the screen reader still hears every change. One link at a time: "All week transactions" or "Whole week". */
#app[data-route=stats] .week-explorer[data-week-selected=""] .week-selection-readout,
#app[data-route=stats] .week-explorer:not([data-week-selected=""]) .week-selection-readout>[data-week-copy=label]{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
#app[data-route=stats] .week-explorer[data-week-selected=""] [data-week-all]{display:none}
#app[data-route=stats] .week-explorer .week-explorer-nav{margin-bottom:4px}
/* Category by month: the title keeps one line; the switch drops below it on narrow phones. */
#app .report-history .report-history-head{flex-wrap:wrap;row-gap:8px}
#app .report-history .report-history-head h2{white-space:nowrap}
/* At a glance page dots: 44 px targets around the same small dot. */
html[data-theme] #app[data-route=stats] .glance-dot{width:44px;height:44px}
html[data-theme] #app[data-route=stats] .glance-dot::before{inset:19px}
html[data-theme] #app[data-route=stats] .stats-glance .glance-dots{gap:0}
/* Revealed cards clear the sticky header and the bottom bar and period chip. */
#app[data-route=stats] :is(.share-row,.cc-card,.week-selected-records){scroll-margin-top:calc(var(--stats-header-height,56px) + 16px);scroll-margin-bottom:calc(96px + env(safe-area-inset-bottom))}
/* Floating month chip: tucks below while the page moves down, returns on the way up or after a pause, and hides while typing. */
.stats-month-chip[data-shown=true][data-typing]{opacity:0;visibility:hidden;pointer-events:none}
.stats-month-chip{touch-action:pan-y;transition:opacity var(--motion-enter) var(--motion-ease),transform var(--motion-move) var(--motion-ease),visibility var(--motion-move)}
/* Away from this month the chip carries a small accent dot: double tap brings the report back. */
.stats-month-chip[data-away]::after{content:"";position:absolute;top:5px;right:9px;width:7px;height:7px;border-radius:50%;background:var(--decorative,#ffbb6a);box-shadow:0 0 0 2px var(--surface)}
/* Where it went, Bar view (2026-11-07): the total the Pie shows in its centre sits on one line above the stacked bar. */
#app[data-route=stats] [data-group-stacked][data-group-mode=bar] .group-chart-reading{display:flex;flex-direction:row;align-items:baseline;justify-content:space-between;gap:12px;margin:0 0 10px;font-size:var(--text-sm);color:var(--muted)}
#app[data-route=stats] [data-group-stacked][data-group-mode=bar] .group-chart-reading strong{order:2;font-size:var(--text-lg,18px);font-weight:600;color:var(--text);font-variant-numeric:tabular-nums}
#app[data-route=stats] [data-group-stacked][data-group-mode=bar] .group-chart-reading span{order:1;min-height:0;line-height:1.3}
