/* Stats & Settings picks (2026-11-26): Answer-first Overview with sticky section labels, hold-the-frame roll,
   spending-so-far chart, treemap, category bottom sheet, category page and the Settings moves.
   Cards stay plain surface, 1px hairline, 20px radius. One rhythm on the 8pt scale. Yellow only marks selection. */

/* ---- Overview: Answer first, sections with sticky labels ---- */
#app[data-route=stats] .sov-lead[data-sov-answer]{display:grid;gap:24px;min-width:0}
#app[data-route=stats] .sov-q{display:grid;gap:8px;min-width:0}
#app[data-route=stats] .stats-studio .sov-q>h2.sov-q-label{position:sticky;top:calc(var(--stats-sticky-top,0px) + var(--stats-controls-h,0px));z-index:3;margin:0 -16px;padding:8px 16px;background:var(--bg);color:var(--muted);font-size:12px;line-height:16px;font-weight:600;letter-spacing:.08em;text-transform:uppercase}
#app[data-route=stats] .sov-q>.card,#app[data-route=stats] .sov-q-card{margin:0;padding:16px;border:1px solid var(--divider);border-radius:20px;background:var(--surface);box-shadow:none}
#app[data-route=stats] .sov-q-card .sov-balance{padding:0;border:0}
/* The breakdown was a borderless block inside the old lead (account-category-polish.css forces that with !important); under Answer first it is a card like the rest. */
#app[data-route=stats] .stats-studio .sov-q>.stats-analyzer.sov-analyzer{padding:16px!important;border:1px solid var(--divider)!important;border-radius:20px!important;background:var(--surface)!important}
#app[data-route=stats] .sov-q .sov-analyzer>.section-heading h2{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
#app[data-route=stats] .sov-q .sov-allowance{margin:0 0 8px}
#app[data-route=stats] .sov-q[data-sov-q=budget]{gap:8px}
#app[data-route=stats] .sov-counted{margin:0;text-align:center}
#app[data-route=stats] .sov-counted .text-button,#app[data-route=stats] .sov-settings-hint .text-button{min-height:44px}
@media(min-width:1024px){#app[data-route=stats] .sov-lead[data-sov-answer]{max-width:760px}}

/* What changed */
#app[data-route=stats] .sov-changed-note{margin:0 0 8px}
#app[data-route=stats] .sov-changed-list{display:grid;margin:0;padding:0;list-style:none}
#app[data-route=stats] .sov-changed-list li+li{border-top:1px solid var(--divider)}
#app[data-route=stats] .sov-changed-row{display:flex;align-items:center;gap:12px;width:100%;min-height:48px;padding:8px 0;border:0;border-radius:12px;background:none;color:var(--text);font:inherit;text-align:left;cursor:pointer}
#app[data-route=stats] .sov-changed-row .glyph-tile{flex:none;width:32px;height:32px}
#app[data-route=stats] .sov-changed-name{flex:1 1 auto;min-width:0;overflow-wrap:anywhere;font-weight:500}
#app[data-route=stats] .sov-changed-amount{flex:none;font-variant-numeric:tabular-nums;font-weight:600}
#app[data-route=stats] .sov-changed-amount[data-trend=up]{color:var(--expense)}
#app[data-route=stats] .sov-changed-amount[data-trend=down]{color:var(--income)}
#app[data-route=stats] .sov-changed-amount .report-amount{color:inherit}
#app[data-route=stats] [data-cat-sheet][data-cat-selected]{background:var(--decorative-soft)}

/* ---- Hold the frame: rolling digits ---- */
/* The rolling digits live inside .sov-lead [data-stats-number]{display:inline} and the hero font rules, so these need the
   extra weight. The number keeps its final width (set from JS before the roll) and never wraps. */
html #app [data-stats-number].hf-rolling{display:inline-flex!important;flex-wrap:nowrap;align-items:flex-start;overflow:hidden;white-space:nowrap;line-height:1.15!important;height:1.15em;vertical-align:bottom;font-variant-numeric:tabular-nums}
html #app [data-stats-number].hf-rolling .hf-col{display:inline-block;flex:none;height:1.15em;overflow:hidden}
html #app [data-stats-number].hf-rolling .hf-stack{display:flex;flex-direction:column;will-change:transform}
html #app [data-stats-number].hf-rolling :is(.hf-stack>span,.hf-char){display:block;flex:none;height:1.15em;line-height:1.15em;white-space:pre}
/* Numbers and labels that move never wrap or change width mid-animation. */
#app[data-route=stats] :is(.sov-total,.sov-balance-line,.stats-period-label,.sov-changed-amount,.dtd-number,.group-chart-reading strong){white-space:nowrap}
#app[data-route=stats] .stats-studio [data-stats-number]{font-variant-numeric:tabular-nums}

/* ---- Spending so far: last month ghost, dashed budget label left, projection to period end ---- */
#app[data-route=stats] .dtd-plot{touch-action:pan-y pinch-zoom;user-select:none;-webkit-user-select:none}
#app[data-route=stats] .dtd-plot .dtd-comp{fill:none;stroke:var(--muted);stroke-width:1.6;opacity:.55;stroke-linejoin:round}
#app[data-route=stats] .dtd-plot .dtd-forecast{fill:none;stroke:var(--dtd-actual-ink,var(--text));stroke-width:2;stroke-dasharray:3 4;opacity:.85}
#app[data-route=stats] .dtd-plot .dtd-forecast-end{fill:var(--dtd-actual-ink,var(--text))}
#app[data-route=stats] .dtd-plot .dtd-forecast-label{fill:var(--muted);font-size:12px}
#app[data-route=stats] .dtd-plot .dtd-budget-label{font-size:12px}
#app[data-route=stats] .dtd-plot .dtd-today{fill:var(--decorative);stroke:var(--dtd-actual-ink,var(--text));stroke-width:1.5}

/* ---- Breakdown: Treemap view, selection = yellow, others dim ---- */
#app[data-route=stats] .group-chart-switch{flex-wrap:nowrap}
/* Three views no longer fit beside Categories | Merchants | People: the switch sits on its own line above the chart. */
#app[data-route=stats] .stats-studio .sov-analyzer [data-group-stacked] .group-chart-head{position:static;justify-content:flex-end;margin:0 0 8px}
#app[data-route=stats] [data-group-mode=tree] .group-chart-bar-caption{visibility:hidden}
#app[data-route=stats] [data-group-mode=tree] .group-chart-shape{cursor:pointer;stroke:none}
#app[data-route=stats] .gc-tree-labels{pointer-events:none}
#app[data-route=stats] :not([data-group-mode=tree])>.group-chart-visual .gc-tree-labels{display:none}
#app[data-route=stats] .gc-tree-name{fill:#fff;font-size:12px;font-weight:600}
#app[data-route=stats] .gc-tree-amount{fill:#fff;font-size:12px;opacity:.92;font-variant-numeric:tabular-nums}
html:is([data-theme=dark],[data-theme=grey-glass]) #app[data-route=stats] :is(.gc-tree-name,.gc-tree-amount){fill:#10150f}
#app[data-route=stats] .gc-tree-labels [data-cat-selected]{fill:var(--on-decorative,#222)}
#app[data-route=stats] .gc-ghost{pointer-events:none}
#app[data-route=stats] .gc-ghost>*{transform-box:fill-box;transform-origin:center}
#app[data-route=stats] [data-group-stacked][data-group-mode=tree] .group-chart-reading{display:flex;flex-direction:row;align-items:baseline;justify-content:space-between;gap:12px;margin:0 0 8px;font-size:var(--text-sm)}
#app[data-route=stats] [data-group-stacked][data-group-mode=tree] .group-chart-reading strong{order:2;font-size:var(--text-lg,18px);font-weight:600;color:var(--text)}
#app[data-route=stats] .stats-group-chart[data-has-selection] .group-chart-shape{opacity:.35;transition:opacity var(--motion-enter,200ms) var(--motion-ease,cubic-bezier(.2,0,0,1))}
#app[data-route=stats] .stats-group-chart[data-has-selection] .group-chart-shape[data-cat-selected]{opacity:1;fill:var(--decorative)}
#app[data-route=stats] .share-row[data-cat-selected]>.share-row-toggle{background:var(--decorative-soft);border-radius:12px}
@media (prefers-reduced-motion:reduce){#app[data-route=stats] .stats-group-chart .group-chart-shape{transition:none}}

/* ---- Category bottom sheet ---- */
dialog.cat-sheet{box-sizing:border-box;width:min(440px,calc(100% - 32px));max-height:min(720px,calc(100dvh - 48px));margin:auto;padding:0;border:1px solid var(--divider);border-radius:20px;background:var(--surface);color:var(--text);overflow:auto}
dialog.cat-sheet::backdrop{background:var(--scrim)}
dialog.cat-sheet .cs-head{padding:16px 16px 8px}
dialog.cat-sheet .cs-title{display:flex;align-items:center;gap:12px}
dialog.cat-sheet .cs-title .glyph-tile{flex:none;width:44px;height:44px}
dialog.cat-sheet h2{margin:0;font-size:var(--text-xl,18px)}
dialog.cat-sheet h2+p{margin:2px 0 0}
dialog.cat-sheet .cs-body{padding:0 16px 16px}
dialog.cat-sheet .cs-amount{margin:8px 0;font-size:var(--display-sm,24px);font-weight:600;font-variant-numeric:tabular-nums}
dialog.cat-sheet .cs-history{display:block;width:100%;height:auto}
dialog.cat-sheet .cs-bar{fill:var(--chart-track)}
dialog.cat-sheet .cs-bar.is-current{fill:var(--stats-chart-blue,var(--reference-blue))}
dialog.cat-sheet .cs-month{fill:var(--muted);font-size:12px}
dialog.cat-sheet .cs-subhead{margin:16px 0 0;color:var(--muted);font-size:12px;font-weight:600;letter-spacing:.08em;text-transform:uppercase}
dialog.cat-sheet .cs-merchants{margin:0;padding:0;list-style:none}
dialog.cat-sheet .cs-merchants li{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:48px;border-bottom:1px solid var(--divider)}
dialog.cat-sheet .cs-merchants span{display:grid;min-width:0;overflow-wrap:anywhere}
dialog.cat-sheet .cs-merchants small{color:var(--muted);font-size:12px}
dialog.cat-sheet .cs-merchants b{flex:none;font-weight:600;font-variant-numeric:tabular-nums}
dialog.cat-sheet .cs-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:16px}
dialog.cat-sheet .cs-actions:empty{display:none}
dialog.cat-sheet .cs-foot{display:flex;padding:8px 16px 16px}
dialog.cat-sheet .cs-foot .button{flex:1;min-height:44px}
@media (max-width:639px){dialog.cat-sheet[data-bottom-sheet]{width:100%}}

/* ---- Settings: help, merchant grouping, category page ---- */
#app .settings-help h3{margin:0 0 8px;font-size:var(--text-base,16px)}
#app .settings-help-item{border-top:1px solid var(--divider)}
#app .settings-help-item>summary{display:flex;align-items:center;min-height:48px;cursor:pointer;font-weight:500}
#app .settings-help-item>p{margin:0 0 8px}
#app #settings-categories .merchant-alias-settings{margin-top:8px;border-top:1px solid var(--divider)}
#app #settings-categories .merchant-alias-settings>summary{display:flex;align-items:center;min-height:48px;cursor:pointer;font-weight:500}
#app #settings-categories #merchant-alias-form{display:grid;gap:8px}
#app #settings-budget .budget-sheet-categories ul{margin:0;padding:0;list-style:none}
#app #settings-budget .budget-sheet-categories li{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:48px;border-top:1px solid var(--divider)}
#app #settings-budget .budget-sheet-categories li>span{display:grid;min-width:0}
#app #settings-budget .budget-sheet-categories small{color:var(--muted)}

.cat-page{display:grid;gap:16px;min-width:0;box-sizing:border-box;width:100%;padding:0 16px 16px}
.cat-page>*{min-width:0}
.cat-page .cp-field input{box-sizing:border-box;width:100%;min-height:44px}
.cat-page .cp-types{display:flex;width:100%}
.cat-page .cp-types>button{flex:1;min-height:44px}
.cat-page .cp-hint{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:44px}
.cat-page .cp-hint p{margin:0}
.cat-page .cp-hint.is-moving{padding:8px 12px;border-radius:12px;background:var(--decorative-soft);color:var(--on-decorative,var(--text))}
.cat-page .cp-tree{display:grid;gap:8px;margin:0;padding:8px;border:1px solid var(--divider);border-radius:20px;background:var(--surface)}
.cat-page ul{margin:0;padding:0;list-style:none}
.cat-page .cp-groups{display:grid;gap:4px}
.cat-page .cp-group{border-radius:16px;padding:4px}
.cat-page .cp-group[data-cp-target]{background:color-mix(in srgb,var(--reference-blue) 10%,transparent)}
.cat-page .cp-group-head,.cat-page .cp-row{display:flex;align-items:center;gap:8px;border-radius:12px}
.cat-page .cp-pick{display:flex;flex:1 1 auto;align-items:center;gap:12px;min-width:0;min-height:48px;padding:4px 8px;border:0;border-radius:12px;background:none;color:var(--text);font:inherit;text-align:left;cursor:pointer}
.cat-page .cp-pick[aria-pressed=true]{background:var(--decorative-soft)}
.cat-page .cp-name{display:grid;min-width:0;overflow-wrap:anywhere}
.cat-page .cp-name small{color:var(--muted);font-size:12px}
.cat-page .cp-tile{flex:none;width:32px;height:32px}
.cat-page .cp-children{padding-left:40px}
.cat-page .cp-item[data-depth="2"]{padding-left:16px}
.cat-page .cp-item[data-depth="3"]{padding-left:32px}
.cat-page .cp-children .cp-row{border-top:1px solid var(--divider);border-radius:0}
.cat-page .cp-menu{flex:none}
.cat-page .cp-count{min-width:24px;text-align:right}
.cat-page .cp-dest-button{flex:none;min-height:44px;padding:0 12px;border:1px solid var(--control-border);border-radius:12px;background:var(--surface);color:var(--text);font:inherit;font-weight:500;cursor:pointer}
.cat-page .cp-top-level{justify-self:start}
.cat-page .cp-new{width:100%;min-height:48px;justify-content:center}
.cat-page .cp-flash{background:var(--decorative-soft)}
.cat-page .cp-create{display:grid;gap:16px}
.cat-page .cp-create-head{display:flex;align-items:center;gap:8px}
.cat-page .cp-create-head h3{margin:0;font-size:var(--text-lg,18px)}
.cat-page .cp-back-icon{transform:scaleX(-1)}
.cat-page .cp-create-card{display:grid;gap:16px;margin:0;padding:16px;border:1px solid var(--divider);border-radius:20px;background:var(--surface)}
.cat-page .cp-preview{display:flex;align-items:center;gap:12px;min-height:56px}
.cat-page .cp-preview>div{display:grid;min-width:0}
.cat-page .cp-preview small{color:var(--muted);font-size:12px;overflow-wrap:anywhere}
.cat-page .cp-tile-large{width:52px;height:52px}
.cat-page .cp-field{display:grid;gap:8px;font-weight:500}
.cat-page .cp-auto{color:var(--link);font-weight:400}
.cat-page .cp-chips{display:flex;flex-wrap:wrap;gap:8px}
.cat-page .cp-chip{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;padding:0 12px;border:1px solid var(--control-border);border-radius:12px;background:var(--surface);color:var(--text);font:inherit;cursor:pointer}
.cat-page .cp-chip[aria-pressed=true]{border-color:var(--decorative);background:var(--decorative);color:var(--on-decorative,var(--text))}
.cat-page .cp-chip .glyph-tile.cp-swatch{display:block;width:20px;height:20px;border-radius:6px;background:var(--glyph-hue,var(--chart-2))}
.cat-page .cp-hues .cp-chip[aria-pressed=true]{background:var(--surface);border-color:var(--decorative);box-shadow:inset 0 0 0 2px var(--decorative)}
@media (hover:hover) and (pointer:fine){
 #app[data-route=stats] .sov-changed-row:hover{background:var(--subtle)}
 .cat-page .cp-pick:hover,.cat-page .cp-chip:hover,.cat-page .cp-dest-button:hover{background:var(--subtle)}
 .cat-page .cp-chip[aria-pressed=true]:hover{background:var(--decorative)}
 .cat-page .cp-hues .cp-chip[aria-pressed=true]:hover{background:var(--surface)}
}
@media (prefers-reduced-motion:reduce){.cat-page *{animation:none!important;transition:none!important}}

/* ---- Stats share card: preview follows the chosen format; options sit under it ---- */
.spend-report[data-preset=card] .spend-report-frame{width:min(100%,300px);background:transparent;box-shadow:0 12px 32px #20274114;border:1px solid var(--divider)}
.spend-report[data-preset=card] canvas{aspect-ratio:auto;height:auto}
.spend-report[data-preset=card]:has([data-card-format=wide][aria-pressed=true]) .spend-report-frame{width:100%}
.spend-report[data-preset=card]:has([data-card-format=square][aria-pressed=true]) .spend-report-frame{width:min(100%,320px)}
.spend-report .report-card-options{display:grid;gap:8px;margin-top:16px}
.spend-report .report-card-options .segmented{display:flex;width:100%}
.spend-report .report-card-options .segmented>button{flex:1;min-height:44px}
.spend-report .report-card-hide{padding:8px 0}

/* ---- The app mark, inline so it can move once at launch (logo-mark.js) ---- */
.brand-mark .logo-mark{display:block;width:100%;height:auto;overflow:visible}
.logo-mark>*{transform-box:fill-box;transform-origin:center}
.startup-status .startup-mark{display:block;width:48px;height:48px;margin:0 0 16px}
.brand-mark:has(>.logo-mark){background:transparent!important;border:0;box-shadow:none;padding:0;border-radius:0}
.safe-area-probe{position:fixed;left:0;top:0;width:0;height:0;visibility:hidden;pointer-events:none;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px)}
