/* spending details view: entry button, sheet (phones) / panel (desktop), charts. Motion = transform / opacity / stroke-dashoffset only; index.html's reduced-motion rule turns it all off */
.insBtn { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 10px; padding: 11px 16px; border: 1px solid var(--border); border-radius: var(--r); text-align: left; color: var(--heading);
  background: var(--sheen), linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), var(--card); box-shadow: var(--hl), var(--lift); animation: rise .45s var(--spring) both; animation-delay: 180ms; }
.insBtn:hover { color: var(--heading); border-color: var(--border-hi); background: var(--sheen), linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, transparent), transparent 70%), var(--card); }
.insBtn .ic { font-size: 18px; } .insBtn b { font-weight: 600; } .insBtn small { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insBtn i { font-style: normal; font-size: 20px; line-height: 1; color: var(--muted); }
.stat.ins-go { cursor: pointer; }
.stat.ins-go::after { content: "›"; position: absolute; top: 9px; right: 13px; font-size: 18px; line-height: 1; color: var(--faint); }
#bdCat .row { cursor: pointer; margin: 0 -6px; padding: 4px 6px; border-radius: 8px; transition: background .15s var(--ease); }
#bdCat .row:hover { background: var(--hover); }

#ins { width: min(1000px, calc(100vw - 48px)); height: min(920px, calc(100dvh - 48px)); max-width: none; max-height: none; overflow: hidden; flex-direction: column; }
#ins[open] { display: flex; }
#ins::backdrop { transition: opacity .26s var(--ease); }
#ins.out { opacity: 0; transform: scale(.97); transition: opacity .2s var(--ease), transform .26s var(--ease); }
#ins.out::backdrop { opacity: 0; }
.ins-head { flex: none; padding: 16px 20px 10px; border-bottom: 1px solid var(--border); }
.ins-grab { display: none; }
.ins-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ins-top h2 { flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#insPer { margin: 0; }
.ins-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 20px 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-content: start; scrollbar-width: thin; outline: none; }
.ins-sec { min-width: 0; padding: 14px 16px; background: var(--sheen), var(--card); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--hl), var(--lift); }
.ins-wide { grid-column: 1 / -1; }
.ins-sec h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--heading); } .ins-sec h3 span { font-weight: 400; color: var(--muted); }
.ins-sec h4 { margin: 0 0 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.ins-muted { color: var(--muted); } p.ins-muted { margin: 6px 0 0; font-size: 13px; }
.sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }

/* hero: the one big number */
.ins-hero { background: var(--sheen), linear-gradient(135deg, color-mix(in srgb, var(--accent) 20%, transparent), color-mix(in srgb, #d946ef 7%, transparent) 55%, transparent), var(--card); padding: 18px 20px; }
.ins-k { display: flex; align-items: center; color: var(--muted); font-size: 13px; font-weight: 500; }
.ins-big { font-size: 52px; font-weight: 700; letter-spacing: -.035em; line-height: 1.1; color: var(--heading); margin: 2px 0 4px; overflow-wrap: anywhere; }
.ins-delta { min-height: 1.5em; color: var(--text); font-size: 13px; }
.ins-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.ins-kpis > div { min-width: 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--panel2) 70%, transparent); border: 1px solid var(--border); }
.ins-kpis span { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.ins-kpis b { display: block; font-size: 19px; font-weight: 650; letter-spacing: -.02em; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-kpis small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-back { margin: -6px 0 6px -10px; color: var(--accent-hi); font-weight: 500; }

/* categories: donut + ranked list */
.ins-cgrid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: center; }
.ins-donut { position: relative; width: 200px; aspect-ratio: 1; }
.ins-donut svg { display: block; width: 100%; height: 100%; }
.ins-donut circle { fill: none; stroke-width: 14; stroke-dashoffset: 0; cursor: pointer; transition: opacity .2s var(--ease); }
.ins-donut.hl circle:not(.on) { opacity: .3; }
.ins-mid { position: absolute; inset: 34px; display: grid; place-content: center; text-align: center; pointer-events: none; }
.ins-mid b { font-size: 20px; font-weight: 700; letter-spacing: -.02em; color: var(--heading); }
.ins-mid span { font-size: 12px; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-list { min-width: 0; }
.ins-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; width: calc(100% + 16px); margin: 0 -8px; padding: 7px 8px; border-radius: 10px; text-align: left; color: var(--text); }
div.ins-row { cursor: default; }
button.ins-row:hover, button.ins-row:focus-visible { background: var(--hover); color: var(--text); }
.ins-name { display: flex; align-items: center; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.ins-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; } .ins-val small { color: var(--muted); font-weight: 400; font-size: 12px; }
.ins-bar { grid-column: 1 / -1; height: 6px; }
.ins-bar i { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; transform-origin: left; }

/* trend: stacked columns, 2px surface gap between segments and bars, 4px rounded tops, square on the baseline */
.ins-leg { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.ins-leg span { display: inline-flex; align-items: center; gap: 6px; } .ins-leg b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.ins-leg i { width: 8px; height: 8px; border-radius: 2px; }
.oth { background: repeating-linear-gradient(135deg, var(--stripe) 0 2px, transparent 2px 5px) var(--track) !important; }
.ins-chart { position: relative; padding: 8px 0 0 46px; }
.ins-plot { position: relative; height: 170px; }
.ins-tick { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border); }
.ins-tick b { position: absolute; right: calc(100% + 6px); top: 0; transform: translateY(-50%); font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ins-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.ins-slot { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; padding: 0 1px; outline: none; border-radius: 4px; }
.ins-slot:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); }
.ins-slot.on { background: var(--hover); }
.ins-col { width: 100%; max-width: 24px; display: flex; flex-direction: column-reverse; gap: 2px; border-radius: 4px 4px 0 0; overflow: hidden; transform-origin: bottom; }
.ins-col i { flex: 1 1 0; min-height: 0; } /* ponytail: flex-grow shares + fixed 2px gaps skew slivers in very short columns; the tooltip/table carry exact values */
.ins-slot.on .ins-col { filter: brightness(1.15); }
.ins-x { position: relative; height: 16px; margin-top: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ins-x span { position: absolute; top: 0; white-space: nowrap; }
.ins-tip { position: absolute; top: 4px; z-index: 3; min-width: 140px; max-width: 220px; padding: 8px 11px; border-radius: 12px; font-size: 12px; pointer-events: none;
  background: var(--sheen), color-mix(in srgb, var(--panel2) 96%, transparent); border: 1px solid var(--border-hi); box-shadow: var(--shadow); animation: fade .15s var(--ease); }
.ins-tip > span { display: block; }
.ins-tt { display: block; font-size: 16px; font-weight: 700; color: var(--heading); margin-bottom: 2px; }
.ins-tip p { display: grid; grid-template-columns: 10px auto minmax(0, 1fr); gap: 7px; align-items: center; margin: 2px 0 0; }
.ins-tip p i { width: 10px; height: 2px; border-radius: 1px; } /* line keys, not boxes */
.ins-tip p b { font-weight: 600; color: var(--heading); font-variant-numeric: tabular-nums; } .ins-tip p span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-tbl { margin-top: 10px; font-size: 12px; color: var(--muted); }
.ins-tbl summary { cursor: pointer; width: max-content; }
.ins-tbl table { min-width: 0; margin-top: 6px; } .ins-tbl td { padding: 5px 6px; color: var(--text); }

/* splits, meter */
.ins-split + .ins-split { margin-top: 14px; }
.ins-stack { display: flex; gap: 2px; height: 10px; border-radius: 4px; overflow: hidden; transform-origin: left; }
.ins-stack i { flex: 1 1 0; min-width: 2px; }
.ins-split .ins-leg { margin: 7px 0 0; }
.ins-meter { height: 8px; margin-top: 8px; border-radius: 4px; background: color-mix(in srgb, var(--c) 18%, transparent); }
.ins-meter i { display: block; height: 100%; border-radius: 4px; background: var(--c); transform-origin: left; }
.ins-sec > .ins-val { font-size: 15px; }

/* entries */
.ins-ents { display: grid; }
.ins-ent { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: calc(100% + 16px); margin: 0 -8px; padding: 8px; border-radius: 10px; text-align: left; color: var(--text); }
.ins-ent + .ins-ent { border-top: 1px solid var(--border); }
.ins-ent:hover { background: var(--hover); color: var(--text); }
.ins-d { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ins-n { min-width: 0; } .ins-n > span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-n small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ins-n .tag { line-height: 18px; margin-right: 2px; }
.ins-ent > b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ins-empty { text-align: center; padding: 40px 16px; color: var(--muted); } .ins-empty > div { font-size: 40px; } .ins-empty b { display: block; color: var(--heading); font-size: 16px; margin: 4px 0; }

/* motion: on open the sections stagger in; on drill / period change everything cross-fades; data refreshes don't replay it */
@keyframes insUp { from { transform: translateY(100%); } }
@keyframes insFade { from { opacity: 0; transform: translateY(6px); } }
@keyframes insSweep { from { stroke-dashoffset: var(--s); } }
.anim > * { animation: rise .5s var(--spring) both; animation-delay: calc(var(--i, 0) * 55ms + 60ms); }
.xf > * { animation: insFade .32s var(--ease) both; }
:is(.anim, .xf) .ins-donut circle { animation: insSweep .9s var(--spring) both; animation-delay: calc(var(--i) * 70ms + 150ms); }
:is(.anim, .xf) .ins-col { animation: growY .55s var(--spring) both; animation-delay: calc(var(--i) * 10ms + 200ms); }
:is(.anim, .xf) :is(.ins-bar i, .ins-stack, .ins-meter i) { animation: grow .8s var(--spring) both; animation-delay: calc(var(--i, 0) * 35ms + 180ms); }

@media (max-width: 640px) {
  .insBtn { padding: 13px 16px; font-size: 15px; }
  #ins { width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; transition: transform .3s cubic-bezier(.4, 0, 1, 1); }
  #ins[open] { animation: insUp .55s var(--spring); }
  #ins.drag { transition: none; }
  #ins.out { opacity: 1; transform: translateY(100%); }
  .ins-head { padding: calc(6px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); background: var(--sheen), color-mix(in srgb, var(--panel) 97%, var(--bg)); }
  .ins-grab { display: block; width: 36px; height: 5px; margin: 0 auto 8px; border-radius: 3px; background: var(--faint); opacity: .6; }
  .ins-top { margin-bottom: 8px; } .ins-top h2 { font-size: 18px; }
  .ins-body { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px max(14px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .ins-sec { padding: 13px 14px; }
  .ins-big { font-size: 44px; }
  .ins-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ins-cgrid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .ins-donut { width: 190px; margin: 0 auto; }
  .ins-plot { height: 150px; }
}
