/* ── Stats / Analytics ─────────────────────────────────────── */
#view-stats {
  position: relative;
}

#view-stats.active {
  flex-direction: column;
}

.stats-toolbar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.stats-filter-row {
  border-bottom: none;
  background: transparent;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 7px;
  gap: 5px;
  align-items: center;
}

.stats-tag-filter-btn {
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

#tx-type-filter .stats-tag-filter-btn.on,
#stats-type-filter .stats-tag-filter-btn.on {
  background: rgba(61, 107, 94, 0.06);
  color: var(--text-2);
  font-weight: 600;
}

.stats-tag-filter-count {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-3);
  letter-spacing: 0;
}

.stats-filter-row .filter-btn {
  padding: 6px 11px;
  border-radius: 20px;
  background: transparent;
  border: none;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text-2);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.stats-filter-row .filter-btn:not(.on):active {
  background: var(--surface-2);
}

.stats-filter-row .filter-btn.on {
  transform: scale(0.98);
  box-shadow: var(--shadow-inset);
  filter: brightness(0.97) saturate(0.98);
  font-weight: 600;
}

#stats-type-filter .filter-btn.on[data-stats-type="all"] {
  background: var(--accent-muted);
  color: var(--accent);
}

#stats-type-filter .filter-btn.on[data-stats-type="income"] {
  background: var(--income-bg);
  color: var(--income);
}

#stats-type-filter .filter-btn.on[data-stats-type="expense"] {
  background: var(--expense-bg);
  color: var(--expense);
}

.stats-filter-row .filter-btn--period {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.stats-filter-row .filter-btn--period:active {
  background: var(--surface-2);
}

.stats-filter-row .filter-btn--period.on {
  background: var(--accent-muted);
  color: var(--accent);
  box-shadow: var(--shadow-inset);
}

.stats-filter-row .filter-btn--period.on svg {
  color: var(--accent);
}

.stats-filter-row .filter-btn--icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  max-width: none;
}

.stats-filter-row .filter-btn--icon svg {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  color: var(--text-2);
}

.stats-tag-filter-list .tag.pickable.picked {
  transform: scale(0.94);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(0, 0, 0, 0.04);
  filter: brightness(0.93) saturate(1.05);
}

.stats-tag-filter-footer {
  display: flex;
  gap: 8px;
}

.stats-tag-filter-footer .btn {
  flex: 1;
}

.stats-screen {
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-chips {
  animation: stats-rise 0.5s cubic-bezier(0.32, 0.72, 0, 1) both;
}

.stats-chips-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

.stats-chips-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.stats-chips-note-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.stats-chips-note-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.stats-cat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.stats-cat-chip:not(.picked) {
  opacity: 0.45;
}

.stats-cat-chip.picked {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.stats-cat-chip:active {
  transform: scale(0.97);
}

.stats-cat-chip-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.stats-hero {
  animation: stats-rise 0.5s cubic-bezier(0.32, 0.72, 0, 1) 60ms both;
}

.stats-hero-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-bottom: 14px;
}

.stats-hero-period {
  flex-shrink: 0;
}

.stats-hero-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  justify-content: flex-end;
}

.stats-hero-tags-strip {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.stats-hero-tags-strip .tag-chip-wrap.is-hidden {
  display: none;
}

.stats-hero-tags-strip .tag {
  font-size: 11px;
  padding: 3px 8px 3px 10px;
}

.stats-hero-tags-strip .tag-rm {
  font-size: 12px;
  opacity: 0.5;
}

.stats-hero-tags-strip .tag-rm:active {
  opacity: 0.85;
}

.stats-hero-tags-more {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-3);
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stats-kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.stats-hero-caption {
  font-size: 12px;
  color: var(--text-3);
}

.stats-trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.stats-metric-val {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-metric-val.inc { color: var(--income); }
.stats-metric-val.exp { color: var(--expense); }

.stats-metric--net {
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.stats-block {
  animation: stats-rise 0.5s cubic-bezier(0.32, 0.72, 0, 1) both;
}

.stats-chart-block { animation-delay: 120ms; }

.stats-chart-panel {
  padding: 16px;
}

.stats-chart-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.stats-donut-wrap {
  position: relative;
  width: 108px;
  height: 108px;
  flex-shrink: 0;
}

.stats-donut {
  width: 108px;
  height: 108px;
  display: block;
}

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

.stats-donut-center-val {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stats-donut-center-val.inc { color: var(--income); }
.stats-donut-center-val.exp { color: var(--expense); }

.stats-donut-center-lbl {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  margin-top: 2px;
}

.stats-legend {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-legend-entry {
  border-radius: 8px;
  overflow: hidden;
  transition: background 0.2s ease;
}

.stats-legend-entry.is-open {
  background: var(--surface-2);
}

.stats-legend-item {
  display: grid;
  grid-template-columns: 8px 1fr auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  animation: stats-rise 0.4s cubic-bezier(0.32, 0.72, 0, 1) calc(180ms + var(--i, 0) * 40ms) both;
}

.stats-legend-item:active {
  filter: brightness(0.97);
}

.stats-legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.stats-legend-item .lbl {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-legend-item .pct {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.stats-legend-item .amt {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-legend-item .amt.inc {
  color: var(--income);
}

.stats-legend-item .amt.exp {
  color: var(--expense);
}

.stats-legend-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.36s cubic-bezier(0.33, 1, 0.68, 1);
}

.stats-legend-entry.is-open .stats-legend-body {
  grid-template-rows: 1fr;
}

.stats-legend-entry .stats-group-list {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.28s ease, transform 0.36s cubic-bezier(0.33, 1, 0.68, 1);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.stats-legend-entry.is-open .stats-group-list {
  opacity: 1;
  transform: translateY(0);
}

.stats-mini-tx {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.stats-mini-tx:last-child { border-bottom: none; }

.stats-mini-tx-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.stats-mini-tx-label {
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-mini-tx-sum {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats-mini-tx-sum.inc { color: var(--income); }
.stats-mini-tx-sum.exp { color: var(--expense); }

.stats-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px 32px;
  animation: stats-rise 0.5s cubic-bezier(0.32, 0.72, 0, 1) 80ms both;
}

.stats-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-3);
  margin-bottom: 12px;
}

.stats-empty p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.stats-empty-hint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-3);
  max-width: 260px;
  line-height: 1.45;
}

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

@media (prefers-reduced-motion: reduce) {
  .stats-chips,
  .stats-hero,
  .stats-block,
  .stats-legend-item,
  .stats-empty,
  .stats-donut-seg,
  .dash-widget-group {
    animation: none !important;
  }

  .dash-widget-group {
    transition: none;
  }

  .dash-widgets:has(.dash-widget-group.is-open) .dash-widget-group:not(.is-open) {
    opacity: 0.5;
    filter: saturate(0.68);
  }

  .dash-widget-body,
  .dash-widget-collapse,
  .dash-widget-chevron,
  .dash-widget-head {
    transition: none;
  }

  .dash-widget-group:not(.is-open) .dash-widget-collapse {
    display: none;
  }

  .dash-widget-group.is-open .dash-widget-collapse {
    opacity: 1;
    transform: none;
  }

  .dash-widget-group .dash-trend-stage {
    transition: none !important;
  }

  .stats-legend-body,
  .stats-legend-entry .stats-group-list {
    transition: none !important;
  }
}

/* ── Dashboard constructor ─────────────────────────────────── */
.dash-widget-group.is-refreshing,
.dash-widget-group.is-chart-swapping,
.dash-widget-group.is-chart-swapping .dash-widget-content,
.dash-widget-group.is-chart-swapping .dash-trend-stage {
  transition: none !important;
}

.dash-widget-content.is-chart-swapping {
  transition: none !important;
}

.dash-widget-granularity-wrap:not(:empty) .dash-widget-granularity {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 14px 10px;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.dash-widget-group.is-open .dash-widget-granularity-wrap:not(:empty) .dash-widget-granularity {
  background: var(--surface);
}

.dash-widget-granularity {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 14px 10px;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.dash-widget-group.is-open .dash-widget-granularity {
  background: var(--surface);
}

.dash-widget-granularity .filter-btn {
  padding: 6px 11px;
  border-radius: 20px;
  background: transparent;
  border: none;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text-2);
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.dash-widget-granularity .filter-btn:not(.on):active {
  background: var(--surface-2);
}

.dash-widget-granularity .filter-btn.on {
  transform: scale(0.98);
  box-shadow: var(--shadow-inset);
  filter: brightness(0.97) saturate(0.98);
  font-weight: 600;
  background: var(--accent-muted);
  color: var(--accent);
}

.dash-screen {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
  padding: 8px 0 12px;
}

.dash-screen--empty {
  align-items: stretch;
  padding: 12px 16px 24px;
  gap: 12px;
}

.dash-widgets {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-widget-group {
  margin: 0 12px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  outline: 1px solid var(--border);
  box-shadow: none;
  touch-action: pan-y;
  transition:
    box-shadow 0.45s cubic-bezier(0.33, 1, 0.68, 1),
    background 0.3s ease,
    outline-color 0.3s ease,
    margin 0.35s cubic-bezier(0.33, 1, 0.68, 1),
    opacity 0.38s cubic-bezier(0.33, 1, 0.68, 1),
    filter 0.38s cubic-bezier(0.33, 1, 0.68, 1);
}

.dash-widgets:has(.dash-widget-group.is-open) .dash-widget-group:not(.is-open) {
  opacity: 0.46;
  filter: saturate(0.62) brightness(0.95);
  animation: none;
}

@media (hover: hover) {
  .dash-widgets:has(.dash-widget-group.is-open) .dash-widget-group:not(.is-open):hover {
    opacity: 0.58;
    filter: saturate(0.74) brightness(0.98);
  }
}

.dash-widgets:has(.dash-widget-group.is-open) .dash-widget-group:not(.is-open):active {
  opacity: 0.52;
  filter: saturate(0.68) brightness(0.96);
}

.dash-widget-group.is-open {
  position: relative;
  z-index: 2;
  margin: 2px 10px;
  overflow: visible;
  background: var(--surface);
  outline: none;
  border: 1px solid var(--overlay-border);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--overlay-border);
}

.dash-widget-group.is-open + .dash-widget-group.is-open {
  margin-top: 0;
}

.dash-widget-group:nth-child(even) {
  background: var(--surface-2);
  outline-color: var(--border);
}

.dash-widget-group:nth-child(even).is-open {
  background: var(--surface);
  border-color: var(--overlay-border);
}

.dash-widget-head-row {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.dash-widget-head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 8px 14px 14px;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  touch-action: pan-y;
  transition: filter 0.15s ease, border-color 0.4s cubic-bezier(0.33, 1, 0.68, 1);
}

.dash-widget-group.is-open .dash-widget-head {
  border-bottom-color: var(--border);
  border-radius: 10px 10px 0 0;
  transition-delay: 0.05s;
}

.dash-widget-head:active {
  filter: brightness(0.98);
}

.dash-widget-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-3);
  opacity: 0.7;
  transform: rotate(0deg);
  transition:
    transform 0.52s cubic-bezier(0.33, 1, 0.68, 1),
    opacity 0.32s ease;
}

.dash-widget-group.is-open .dash-widget-chevron {
  transform: rotate(90deg);
  opacity: 1;
}

.dash-widget-group:not(.is-open) .dash-widget-chevron {
  transition:
    transform 0.36s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.24s ease;
}

.dash-widget-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-widget-sum {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -0.01em;
  text-align: right;
  flex-shrink: 0;
  color: var(--text-3);
  line-height: 1;
}

.dash-widget-sum.inc { color: var(--income); }
.dash-widget-sum.exp { color: var(--expense); }
.dash-widget-sum.muted { color: var(--text-3); font-weight: 500; }

.dash-widget-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  align-items: center;
  align-self: center;
  padding-right: 14px;
}

.dash-widget-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
}

.dash-widget-btn-icon {
  width: 17px;
  height: 17px;
  display: block;
  flex-shrink: 0;
}

.dash-widget-btn:active {
  background: var(--surface-2);
}

.dash-widget-group .dash-widget-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.36s cubic-bezier(0.4, 0, 0.2, 1);
}

.dash-widget-group:not(.is-open) .dash-widget-body {
  pointer-events: none;
}

.dash-widget-group.is-open .dash-widget-body {
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.54s cubic-bezier(0.22, 1, 0.36, 1);
}

.dash-widget-collapse {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  background: transparent;
  transition:
    opacity 0.22s cubic-bezier(0.4, 0, 1, 1),
    transform 0.34s cubic-bezier(0.4, 0, 0.2, 1);
}

.dash-widget-group.is-open .dash-widget-collapse {
  opacity: 1;
  transform: translateY(0);
  background: var(--surface-2);
  border-radius: 0 0 10px 10px;
  transition:
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1) 0.08s,
    transform 0.54s cubic-bezier(0.22, 1, 0.36, 1) 0.05s;
}

.dash-widget-content {
  overflow: hidden;
  min-height: 0;
}

.dash-widget-group.is-open .dash-widget-content {
  padding: 12px 14px 14px;
  border-radius: 0 0 10px 10px;
}

.dash-widget-group.is-open.dash-widget-group--trend .dash-widget-content {
  min-height: 0;
  padding: 8px 12px 10px;
  overflow: visible;
}

.dash-widget-group.is-open.dash-widget-group--trend .dash-widget-granularity {
  padding: 0 12px 6px;
}

.dash-widget-group.is-open.dash-widget-group--categories .dash-widget-content {
  min-height: 420px;
}

.dash-widget-foot {
  padding: 0 0 4px;
}

.dash-widget-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--text-3);
}

.dash-empty-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  padding: 12px 0;
}

.dash-tags-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 16px 12px;
}

.dash-add-btn {
  width: calc(100% - 24px);
  margin: 8px 12px 0;
}

.dash-vbars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  padding-top: 4px;
}

.dash-vbars--signed {
  align-items: stretch;
  padding-top: 0;
  min-height: 0;
  --signed-track-h: 120px;
  --signed-val-space: 1.35em;
  --signed-bar-w: 62%;
}

.dash-bars.is-expanded .dash-vbars--signed {
  --signed-track-h: 136px;
  --signed-bar-w: 68%;
}

.dash-bars.is-expanded .dash-vbars {
  min-height: 220px;
  gap: 12px;
}

.dash-bars--signed.is-expanded .dash-vbars {
  min-height: 0;
  height: auto;
}

.dash-vbar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  max-width: 80px;
  transition: transform 0.15s ease;
}

.dash-vbar-col--signed {
  display: grid;
  grid-template-rows: calc(var(--signed-track-h) + var(--signed-val-space)) auto;
  gap: 0;
  align-items: stretch;
  justify-items: center;
  width: 100%;
}

.dash-vbar-col.is-active {
  transform: translateY(-2px);
}

.dash-vbar-col.is-active .dash-vbar-fill {
  filter: brightness(1.05);
  box-shadow: var(--shadow-md);
}

.dash-vbar-track {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.dash-vbar-track--signed {
  grid-row: 1;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  overflow: hidden;
  padding-top: var(--signed-val-space);
  box-sizing: border-box;
}

.dash-vbar-col--signed .dash-vbar-zone {
  overflow: hidden;
}

.dash-vbar-fill-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--signed-bar-w, 62%);
  min-height: 0;
}

.dash-vbar-fill-stack .dash-vbar-fill {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
}

.dash-vbar-col--signed .dash-vbar-zone > .dash-vbar-fill {
  width: var(--signed-bar-w, 62%);
}

.dash-bars.is-expanded .dash-vbar-track:not(.dash-vbar-track--signed) {
  height: 180px;
}

.dash-vbar-zone {
  display: flex;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.dash-vbar-zone--pos {
  flex: var(--pos-weight, 1) 1 0;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.dash-vbar-zone--neg {
  flex: var(--neg-weight, 1) 1 0;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

.dash-vbar-axis {
  flex: 0 0 1px;
  flex-shrink: 0;
  width: 100%;
  height: 1px;
  background: var(--border-strong);
  opacity: 0.85;
}

.dash-vbar-val--signed {
  flex-shrink: 0;
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.dash-vbar-val--above-axis {
  align-self: center;
  margin-bottom: 3px;
}

.dash-vbar-col--signed .dash-vbar-lbl {
  grid-row: 2;
  margin-top: 8px;
}

.dash-vbar-fill {
  width: 62%;
  min-height: 0;
  border-radius: 4px 4px 2px 2px;
  transition: height 0.4s cubic-bezier(0.33, 1, 0.68, 1), filter 0.15s ease, box-shadow 0.15s ease;
}

.dash-vbar-zone--pos .dash-vbar-fill {
  border-radius: 4px 4px 1px 1px;
}

.dash-vbar-zone--neg .dash-vbar-fill {
  border-radius: 1px 1px 4px 4px;
}

.dash-bars.is-expanded .dash-vbar-fill {
  width: 68%;
}

.dash-vbar-col--signed .dash-vbar-fill-stack .dash-vbar-fill {
  width: 100%;
}

.dash-bars.is-expanded .dash-vbar-col--signed .dash-vbar-zone > .dash-vbar-fill {
  width: var(--signed-bar-w, 68%);
}

.dash-vbar-fill.inc { background: var(--income) !important; }
.dash-vbar-fill.exp { background: var(--expense) !important; }
.dash-vbar-fill.net { background: var(--chart-net) !important; }

.dash-vbar-val {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  line-height: 1.2;
  white-space: nowrap;
}

.dash-vbar-val--top {
  grid-row: 1;
  align-self: end;
}

.dash-vbar-val.is-empty {
  visibility: hidden;
}

.dash-vbar-col--signed[data-metric="expense"] .dash-vbar-val--signed {
  color: var(--expense);
}

.dash-vbar-col--signed[data-metric="income"] .dash-vbar-val--signed {
  color: var(--income);
}

.dash-vbar-col--signed[data-metric="net"] .dash-vbar-val--signed,
.dash-vbar-col--signed[data-metric="balance"] .dash-vbar-val--signed {
  color: var(--chart-net);
}

.dash-vbar-lbl {
  font-size: 10px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.dash-bars.is-expanded .dash-vbar-lbl {
  font-size: 11px;
}

.dash-hbars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-bars.is-expanded .dash-hbars {
  gap: 14px;
}

.dash-hbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.dash-hbar-row.is-active {
  background: var(--surface-2);
}

.dash-bars.is-expanded .dash-hbar-track {
  height: 12px;
}

.dash-hbar-lbl {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-hbar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.dash-hbar-fill {
  height: 100%;
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.4s cubic-bezier(0.33, 1, 0.68, 1);
}

.dash-hbar-val {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.dash-hbars--signed {
  gap: 12px;
}

.dash-bars.is-expanded .dash-hbars--signed {
  gap: 14px;
}

.dash-hbar-track--signed {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  height: 8px;
  background: transparent;
  overflow: visible;
  border-radius: 0;
}

.dash-bars.is-expanded .dash-hbar-track--signed {
  height: 12px;
}

.dash-hbar-zone {
  display: flex;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surface-2);
}

.dash-hbar-zone--neg {
  flex: var(--neg-weight, 1) 1 0;
  justify-content: flex-end;
  border-radius: 4px 0 0 4px;
}

.dash-hbar-zone--pos {
  flex: var(--pos-weight, 1) 1 0;
  justify-content: flex-start;
  border-radius: 0 4px 4px 0;
}

.dash-hbar-track--signed .dash-hbar-axis {
  flex: 0 0 2px;
  flex-shrink: 0;
  align-self: stretch;
  background: var(--border-strong);
  opacity: 0.85;
  z-index: 1;
}

.dash-hbar-zone--neg .dash-hbar-fill {
  border-radius: 4px 1px 1px 4px;
}

.dash-hbar-zone--pos .dash-hbar-fill {
  border-radius: 1px 4px 4px 1px;
}

.dash-hbar-fill.net {
  background: var(--chart-net) !important;
}

.dash-hbar-fill.exp {
  background: var(--expense) !important;
}

.dash-hbar-val--signed {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dash-hbar-row--signed[data-metric="net"] .dash-hbar-val--signed,
.dash-hbar-row--signed[data-metric="balance"] .dash-hbar-val--signed {
  color: var(--chart-net);
}

.dash-hbar-row--signed.is-negative .dash-hbar-val--signed {
  color: var(--expense);
}

.dash-hbar-row--signed.is-positive .dash-hbar-val--signed {
  color: var(--chart-net);
}

.dash-bars-stage {
  position: relative;
}

.dash-chart-tooltip,
.dash-bars-tooltip,
.dash-cat-tooltip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

.dash-bars-tooltip {
  min-width: 120px;
}

.dash-tip {
  min-width: 140px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.dash-tip-title {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-3);
  margin-bottom: 8px;
}

.dash-tip-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-tip-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.dash-tip-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.dash-tip-lbl {
  color: var(--text-2);
}

.dash-tip-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.dash-trend-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-trend-stage {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  max-height: 168px;
  overflow: hidden;
  transition: max-height 0.38s cubic-bezier(0.33, 1, 0.68, 1);
}

.dash-trend-wrap.is-expanded .dash-trend-stage {
  max-height: 168px;
}

.dash-trend-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  pointer-events: none;
}

.dash-trend-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 5;
  opacity: 0.5;
}

.dash-trend-grid--zero {
  stroke: var(--text-3);
  stroke-dasharray: none;
  opacity: 0.75;
}

.dash-trend-y-lbl {
  font-size: 9px;
  fill: var(--text-3);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.dash-trend-axis {
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.7;
}

.dash-trend-area {
  opacity: 0.95;
}

.dash-trend-line {
  vector-effect: non-scaling-stroke;
  opacity: 0.92;
}

.dash-trend-dot {
  transition: opacity 0.12s ease, r 0.12s ease;
}

.dash-trend-xlabels {
  position: relative;
  height: 16px;
  margin: 0;
  pointer-events: none;
}

.dash-trend-xlabels--rotated {
  height: 36px;
}

.dash-trend-xlbl {
  position: absolute;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.2;
  transition: color 0.12s ease, font-weight 0.12s ease;
}

.dash-trend-xlabels--rotated .dash-trend-xlbl {
  transform: translateX(-50%) rotate(-38deg);
  transform-origin: top center;
  max-width: 64px;
}

.dash-trend-xlbl.is-active {
  color: var(--text);
  font-weight: 600;
}

.dash-trend-wrap.is-expanded .dash-trend-xlbl {
  font-size: 11px;
}

.dash-chart-overlay,
.dash-trend-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: none;
  cursor: crosshair;
}

.dash-trend-crosshair {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  pointer-events: none;
  transform: translateX(-0.5px);
}

.dash-trend-crosshair::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 3px;
  background: var(--accent);
  opacity: 0.4;
}

.dash-trend-tooltip {
  top: 8px;
}

.dash-trend-tooltip.is-shown {
  display: block;
}

.dash-cat-chart.is-expanded .dash-cat-row {
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.dash-cat-donut--lg {
  width: 220px !important;
  height: 220px !important;
}

.dash-cat-donut--lg .stats-donut {
  width: 220px;
  height: 220px;
}

.dash-cat-donut--lg .stats-donut-center-val {
  font-size: 17px;
}

.dash-cat-donut--lg .stats-donut-center-lbl {
  font-size: 11px;
}

.dash-cat-legend {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
}

.dash-cat-legend-divider {
  width: 1px;
  background: var(--border-strong);
  align-self: stretch;
  min-height: 100%;
}

.dash-cat-legend-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: opacity 0.15s ease;
}

.dash-cat-legend-col.is-dimmed {
  opacity: 0.45;
}

.dash-cat-legend-col--inc {
  padding-right: 14px;
}

.dash-cat-legend-col--exp {
  padding-left: 14px;
}

.dash-cat-legend-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-cat-legend-empty {
  margin: 0;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-3);
}

.dash-cat-legend-item {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  margin: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.dash-cat-legend-item:hover:not(.is-off),
.dash-cat-legend-item.is-highlighted {
  background: var(--surface-2);
}

.dash-cat-legend-item.is-highlighted {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-2) 22%, transparent);
}

.dash-cat-legend-item.is-dimmed:not(.is-off) {
  opacity: 0.42;
}

.dash-cat-legend-item.is-highlighted.is-dimmed {
  opacity: 1;
}

.dash-cat-legend-item.is-off {
  opacity: 0.55;
}

.dash-cat-legend-item.is-off .lbl,
.dash-cat-legend-item.is-off .amt {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 55%, var(--text-3));
}

.dash-cat-legend-item.is-off .dot {
  opacity: 0.35;
}

.dash-cat-legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.dash-cat-legend-item .lbl {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-cat-legend-item .amt {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dash-cat-legend-item .amt.inc {
  color: var(--income);
}

.dash-cat-legend-item .amt.exp {
  color: var(--expense);
}

.dash-cat-group {
  pointer-events: none;
  opacity: 0.5;
  stroke-width: 6;
  transition:
    opacity 0.15s ease,
    stroke 0.15s ease,
    stroke-width 0.15s ease,
    filter 0.15s ease,
    r 0.15s ease;
}

.dash-cat-group--inc {
  stroke: color-mix(in srgb, var(--income) 38%, var(--surface-2));
}

.dash-cat-group--exp {
  stroke: color-mix(in srgb, var(--expense) 38%, var(--surface-2));
}

.dash-cat-group.is-dimmed {
  opacity: 0.5;
  stroke-width: 6;
}

.dash-cat-group.is-active {
  opacity: 1;
  stroke-width: 8.5;
  filter: brightness(1.12);
}

.dash-cat-group.is-active.dash-cat-group--inc {
  stroke: color-mix(in srgb, var(--income) 88%, var(--surface-2));
}

.dash-cat-group.is-active.dash-cat-group--exp {
  stroke: color-mix(in srgb, var(--expense) 88%, var(--surface-2));
}

.dash-cat-seg {
  cursor: pointer;
  pointer-events: stroke;
  stroke-width: 16;
  transition: stroke-width 0.15s ease, opacity 0.15s ease, filter 0.15s ease, r 0.15s ease;
}

.dash-cat-seg:hover {
  filter: brightness(1.06);
}

.dash-cat-seg.is-highlighted {
  stroke-width: 18;
  filter: brightness(1.06);
}

.dash-cat-seg.is-dimmed {
  opacity: 0.28;
}

.dash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 1px;
}

.dash-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-2);
}

.dash-trend-wrap .dash-legend-chip {
  font-size: 10px;
}

.dash-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.dash-cat-row {
  margin: 0;
}

.dash-type-row {
  flex-wrap: wrap;
  gap: 5px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  overflow: visible;
}

.dash-type-row .filter-btn {
  padding: 6px 11px;
  border-radius: 20px;
  background: transparent;
  border: none;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text-2);
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.dash-type-row .filter-btn:not(.on):active {
  background: var(--surface-2);
}

.dash-type-row .filter-btn.on {
  transform: scale(0.98);
  box-shadow: var(--shadow-inset);
  filter: brightness(0.97) saturate(0.98);
  font-weight: 600;
  background: var(--accent-muted);
  color: var(--accent);
}

.dash-widget-modal {
  max-height: 82dvh;
}

.dash-modal-body {
  gap: 14px;
  padding: 12px 16px 16px;
}

.dash-modal-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.dash-modal-config .field {
  margin: 0;
}

/* Unified dashboard settings pickers */
.dash-widget-modal .dash-settings-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-widget-modal .dash-settings-block--tags {
  gap: 12px;
}

.dash-widget-modal .dash-settings-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dash-widget-modal .dash-pick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dash-widget-modal .dash-pick-btn {
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--surface);
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-2);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--border);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.dash-widget-modal .dash-pick-btn:not(.on):active {
  transform: scale(0.98);
  background: var(--surface-2);
}

.dash-widget-modal .dash-pick-btn.on {
  transform: scale(0.96);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(0, 0, 0, 0.04),
    inset 0 0 0 1px rgba(61, 107, 94, 0.22);
  filter: brightness(0.97) saturate(1.02);
  font-weight: 600;
  background: var(--accent-muted);
  color: var(--accent);
}

.dash-widget-modal .dash-pick-btn.on[data-dash-metric="income"] {
  background: color-mix(in srgb, var(--income) 14%, var(--surface));
  color: var(--income);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(0, 0, 0, 0.03),
    inset 0 0 0 1px color-mix(in srgb, var(--income) 32%, var(--mix-base));
}

.dash-widget-modal .dash-pick-btn.on[data-dash-metric="expense"] {
  background: color-mix(in srgb, var(--expense) 14%, var(--surface));
  color: var(--expense);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(0, 0, 0, 0.03),
    inset 0 0 0 1px color-mix(in srgb, var(--expense) 32%, var(--mix-base));
}

.dash-widget-modal .dash-pick-btn.on[data-dash-metric="net"] {
  background: color-mix(in srgb, var(--chart-net) 16%, var(--surface));
  color: var(--chart-net);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(0, 0, 0, 0.03),
    inset 0 0 0 1px color-mix(in srgb, var(--chart-net) 32%, var(--mix-base));
}

.dash-widget-modal .stats-tag-filter-list .tag.pickable:not(.picked) {
  opacity: 0.55;
}

.dash-widget-modal .stats-tag-filter-list .tag.pickable.picked {
  transform: scale(0.96);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(0, 0, 0, 0.04);
  filter: brightness(0.93) saturate(1.05);
}

.dash-widget-modal .dash-settings-footer {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.dash-widget-modal .dash-settings-footer .btn {
  flex: 1;
  min-width: 0;
}

.dash-config-note {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-3);
}

.field-hint-inline {
  font-weight: 400;
  color: var(--text-3);
  font-size: 12px;
}

/* legacy stats helpers kept for subviews */
.stat-hero {
  text-align: center;
  padding: 20px 16px;
}

.stat-hero .value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--income);
}

.stat-hero .caption {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.chart-row {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 8px 0;
}

.donut { width: 100px; height: 100px; flex-shrink: 0; }

.legend { flex: 1; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}

.legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-item .lbl { flex: 1; color: var(--text-2); }
.legend-item .amt { font-weight: 600; }
