/* Stats: ring card, ranked list, year bars and monthly table. Same family as the Transactions header and panel. */

:root {
  /* ring steps, largest category first; every step is 3:1 or more on the page and the card */
  --ring-1: var(--wine-800); --ring-2: var(--wine-600); --ring-3: var(--wine-500); --ring-4: var(--wine-400); --ring-5: #e0507e;
  --ring-other: #757579;
}
@media (prefers-color-scheme: dark) {
  :root { --ring-1: #ffc2d4; --ring-2: var(--wine-200); --ring-3: #e45585; --ring-4: var(--wine-400); --ring-5: #c43462; --ring-other: #8e8e93; }
}
/* colours arrive as fill="var(--ring-n)"; also set them in CSS for browsers that ignore var() in SVG attributes */
.ring [fill="var(--ring-1)"], .bars [fill="var(--ring-1)"] { fill: var(--ring-1); }
.ring [fill="var(--ring-2)"] { fill: var(--ring-2); }
.ring [fill="var(--ring-3)"] { fill: var(--ring-3); }
.ring [fill="var(--ring-4)"] { fill: var(--ring-4); }
.ring [fill="var(--ring-5)"] { fill: var(--ring-5); }
.ring [fill="var(--ring-other)"] { fill: var(--ring-other); }
.bars [fill="var(--income)"] { fill: var(--income); }

.st-head h1 { flex: 1; min-width: 0; margin: 0; font-size: min(var(--fs-hero), 7.5vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* "November 2026" and Now fit at 360 px */
.st-head .nav:last-of-type { margin-left: 0; }
.pick-btn small { font-size: .5em; font-weight: 700; color: var(--text-2); margin-left: 4px; letter-spacing: 0; }
.pick-btn { position: relative; border-radius: 10px; padding: 0 2px; text-decoration: underline dotted 2px; text-underline-offset: 6px; text-decoration-color: var(--text-2); }
.st-head .year { color: var(--wine-600); }
@media (prefers-color-scheme: dark) { .st-head .year { color: var(--wine-200); } }
.st-kinds { margin-bottom: var(--sp-3); }

.st-ring { padding: var(--sp-3) 0 var(--sp-2); }
.st-flow { width: 9.5rem; margin: 0 auto; }
.st-flow button { min-height: 36px; }
.ring-wrap { display: grid; place-items: center; padding: var(--sp-3) 0 var(--sp-1); touch-action: pan-y; }
.ring { width: min(220px, 62vw); height: auto; overflow: visible; }
.ring .big { font-size: 22px; font-weight: 700; fill: var(--text); letter-spacing: -.02em; }
.ring .small { font-size: 12px; fill: var(--text-2); }
.st-totals { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; margin: var(--sp-2) var(--sp-3) 0; font-size: var(--fs-small); color: var(--text-2); }
.st-totals b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.neg { color: var(--wine-500) !important; } /* 6:1 on white; --warn is 4.35:1, too light for small text */
@media (prefers-color-scheme: dark) { .neg { color: var(--wine-200) !important; } }

.st-list { margin-top: var(--sp-3); }
.srow { display: flex; gap: 10px; align-items: center; width: 100%; min-height: 56px; padding: 8px var(--sp-3); text-align: left; border-bottom: .5px solid var(--separator); }
.srow:last-child { border-bottom: 0; }
.srow:active { background: var(--fill); }
.srow .tile { flex: none; }
.s-body { flex: 1; min-width: 0; }
.s-body .l1 { display: flex; align-items: center; gap: 6px; }
.s-body .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-body .l1 b { font-variant-numeric: tabular-nums; font-weight: 600; }
.s-body .fx { flex: none; font-size: var(--fs-tiny); font-weight: 700; border-radius: 8px; padding: 2px 7px; background: var(--fill); color: var(--text-2); }
.s-body .l2 { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: var(--fs-small); color: var(--text-2); }
.s-body .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.s-body .cmp { margin-left: auto; }

.st-year .group-title .legend { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text-2); }
.legend .k { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.legend .k.in { background: var(--income); }
.legend .k.out { background: var(--ring-1); }
.st-bars { padding: var(--sp-3) var(--sp-2) var(--sp-1); margin-bottom: var(--sp-3); }
.bars { width: 100%; height: auto; display: block; }
.bars text { font-size: 11px; fill: var(--text-2); }
.bars g.on text { fill: var(--text); font-weight: 700; }
.bars .avg { stroke: var(--text-2); stroke-dasharray: 4 3; }
.st-table { margin-bottom: var(--sp-3); }
.tr { display: grid; grid-template-columns: 3rem 1fr 1fr 1fr; gap: 4px; align-items: center; width: 100%; min-height: var(--tap); padding: 0 var(--sp-3);
  font-size: var(--fs-small); font-variant-numeric: tabular-nums; text-align: right; border-bottom: .5px solid var(--separator); }
.tr > :first-child { text-align: left; }
.tr.th { min-height: 32px; color: var(--text-2); font-weight: 600; }
.tr.total { font-weight: 700; border-bottom: 0; }
button.tr:active { background: var(--fill); }
button.tr:disabled { color: var(--text-2); }

/* category sheet */
.cs-avg { margin: 0 var(--sp-5) var(--sp-2); font-weight: 600; }
.cs-bars { background: var(--surface); border-radius: var(--r-row); margin: 0 var(--sp-3) var(--sp-2); padding: var(--sp-3) var(--sp-2) var(--sp-1); box-shadow: var(--shadow-card); }
.cs-bars .bars g { cursor: pointer; }
[data-catsheet] .group-title { align-items: center; }
[data-catsheet] .row-body b { font-variant-numeric: tabular-nums; font-weight: 600; }

/* budgets */
.st-bud-title { align-items: center; margin-top: var(--sp-5); }
.st-bud-none { margin: 0 var(--sp-5) var(--sp-3); }
.st-buds { margin-bottom: var(--sp-3); }
.bud { padding: 10px var(--sp-3); border-bottom: .5px solid var(--separator); }
.bud:last-child { border-bottom: 0; }
.bud small { display: block; margin-top: 4px; font-size: var(--fs-small); color: var(--text-2); font-variant-numeric: tabular-nums; }
.meter { display: block; height: 8px; margin-top: 6px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--ring-2); }
.meter.over i { background: var(--warn); }

/* invisible but tappable: the native date input covers the title */
.pick-over { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; border: 0; padding: 0; cursor: pointer; }
.pick-btn:has(.pick-over:focus-visible) { outline: 2px solid var(--tint); outline-offset: 2px; }
