.visualizations-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.visualizations-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.viz-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.viz-chart-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Always visible now, not a collapsed-by-default disclosure, and every
   field is the real live control (a <select>), not a separate summary row
   underneath restating the same thing in a different style. */
.viz-config-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.viz-config-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.viz-config-card-head .finance-section-toggle {
  width: auto;
  flex: 1 1 auto;
}

.viz-config-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.viz-config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.viz-config-static {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  padding: 7px 0;
}

@media (max-width: 640px) {
  .viz-config-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.viz-focus-widget-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.viz-chart-section {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.viz-chart-section--disabled {
  opacity: 0.62;
}

.viz-chart-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.viz-chart-section-toggle:hover {
  background: var(--surface);
}

.viz-chart-section-toggle:disabled {
  cursor: not-allowed;
}

.viz-chart-section-title {
  font-size: 13px;
  font-weight: 750;
}

.viz-chart-section-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}

.viz-chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.viz-chart-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  padding: 7px 12px;
  cursor: pointer;
}

.viz-chart-tab:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.viz-chart-tab--active {
  border-color: var(--accent);
  background: var(--accent-soft, color-mix(in srgb, var(--accent) 11%, var(--surface)));
  color: var(--accent-strong, var(--accent));
}

.viz-chart-tab:disabled,
.viz-chart-tab--disabled,
.viz-option:disabled,
.viz-option--disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.viz-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.viz-control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.viz-control-label {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.viz-control-clear-row {
  display: flex;
  justify-content: flex-end;
}

.viz-option {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 11.5px;
  padding: 6px 9px;
  cursor: pointer;
}

.viz-option:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.viz-option--active {
  border-color: var(--accent);
  background: var(--accent-soft, color-mix(in srgb, var(--accent) 11%, var(--surface)));
  color: var(--accent-strong, var(--accent));
  font-weight: 650;
}

.viz-date-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.viz-date-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 132px;
}

.viz-date-field span {
  font-size: 10px;
  color: var(--text-faint);
}

.viz-date-field input {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 5px 7px;
}

.viz-custom-range {
  margin-top: 6px;
}
.viz-custom-range summary {
  list-style: none;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 4px 0;
}
.viz-custom-range summary::-webkit-details-marker { display: none; }
.viz-custom-range summary:hover { color: var(--text); }
.viz-custom-range .viz-date-row--custom {
  margin-top: 8px;
}

.viz-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.viz-summary-item {
  border-top: 1px solid var(--border);
  padding-top: 7px;
  min-width: 0;
}

.viz-summary-label {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.viz-summary-value {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.viz-note,
.viz-empty {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.45;
}

.viz-empty {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.viz-plain-stat {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.viz-plain-stat-value {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 22px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.viz-chart-wrap {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.viz-sankey-svg,
.viz-bar-svg,
.viz-pie-svg,
.viz-heatmap-svg {
  display: block;
  width: 100%;
  height: auto;
}

.cashflow-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cashflow-chart-zoom {
  margin-bottom: 2px;
}

.cashflow-chart-wrap {
  position: relative;
  touch-action: pan-y;
}

.cashflow-chart-svg {
  display: block;
  width: 100%;
  height: 168px;
  touch-action: none;
  cursor: crosshair;
}

.cashflow-chart-gridline {
  stroke: var(--border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.cashflow-chart-gridline--x {
  opacity: 0.5;
}

.cashflow-chart-axis-label {
  font-size: 9px;
  fill: var(--text-faint);
}

.cashflow-chart-axis-label--y {
  font-variant-numeric: tabular-nums;
}

.cashflow-chart-zero {
  stroke: var(--risk);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.45;
  vector-effect: non-scaling-stroke;
}

.cashflow-chart-line {
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.cashflow-chart-dot {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 1.5;
}

.cashflow-chart-dot--neg {
  fill: var(--risk);
}

.cashflow-chart-crosshair {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 2 2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.cashflow-chart-scrub-dot {
  fill: var(--accent-strong);
  stroke: var(--surface);
  stroke-width: 1.5;
  pointer-events: none;
}

.cashflow-chart-tooltip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 10px));
  background: var(--text);
  color: var(--surface);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: 1;
}

.cashflow-chart-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
}

.cashflow-chart-tooltip--flip {
  transform: translate(-90%, calc(-100% - 10px));
}
.cashflow-chart-tooltip--flip::after {
  left: 90%;
}

.cashflow-chart-caption {
  font-size: 11px;
  color: var(--text-faint);
}

.viz-bar-track {
  fill: var(--surface-raised);
  cursor: pointer;
}

.viz-bar {
  fill: var(--series-color, var(--data-neutral));
  opacity: 0.78;
  cursor: pointer;
}

.viz-bar--focus {
  fill: var(--data-focus);
  opacity: 0.9;
}

.viz-bar--leftover {
  fill: var(--positive);
  opacity: 0.82;
}

.viz-bar--shortfall {
  fill: var(--risk);
  opacity: 0.82;
}

.viz-bar-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
}

.viz-bar-label--focus {
  fill: var(--text);
  font-weight: 700;
}

.viz-bar-value {
  fill: var(--text-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.viz-bar-total-label,
.viz-sankey-total-label {
  fill: var(--text-faint);
  font-size: 10px;
  text-anchor: end;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.viz-bar-total,
.viz-sankey-total {
  fill: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-anchor: end;
  font-variant-numeric: tabular-nums;
}

.viz-pie-slice {
  fill: var(--series-color, var(--data-neutral));
  opacity: 0.82;
  stroke: var(--surface);
  stroke-width: 2;
  cursor: pointer;
}

.viz-pie-slice--focus {
  fill: var(--data-focus);
  opacity: 0.9;
}

.viz-pie-hole {
  fill: var(--surface);
}

.viz-pie-total-label {
  fill: var(--text-faint);
  font-size: 10px;
  text-anchor: middle;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.viz-pie-total {
  fill: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
}

.viz-pie-key {
  fill: var(--series-color, var(--data-neutral));
  opacity: 0.84;
  cursor: pointer;
}

.viz-pie-key--focus {
  fill: var(--data-focus);
  opacity: 0.95;
}

.viz-pie-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
}

.viz-pie-label--focus {
  fill: var(--text);
  font-weight: 700;
}

.viz-pie-value {
  fill: var(--text-faint);
  font-size: 10px;
  text-anchor: end;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.viz-heatmap-axis {
  fill: var(--text-faint);
  font-size: 10px;
  font-weight: 650;
}

.viz-heatmap-axis--month {
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.viz-heatmap-cell {
  fill: var(--data-focus);
  opacity: calc(0.28 + (var(--heat, 0) * 0.72));
}

/* A day with no activity reads as an empty square on the grid, a neutral
   ground color, not a very-faint green, same distinction GitHub's own
   graph makes between "no contributions" and "one small contribution." */
.viz-heatmap-cell--empty {
  fill: var(--surface-raised);
  opacity: 1;
}

.viz-sankey-flow {
  fill: none;
  stroke: var(--data-neutral);
  stroke-linecap: round;
  opacity: 0.34;
  cursor: pointer;
}

.viz-sankey-flow--focus {
  stroke: var(--data-focus);
  opacity: 0.68;
}

.viz-sankey-flow--leftover {
  stroke: var(--positive);
  opacity: 0.48;
}

.viz-sankey-flow--shortfall {
  stroke: var(--risk);
  opacity: 0.48;
}

.viz-sankey-source-node,
.viz-sankey-target-node {
  fill: var(--data-neutral);
  opacity: 0.62;
}

.viz-sankey-target-node { cursor: pointer; }
.viz-sankey-target-node--color-0 { fill: var(--viz-series-0); }
.viz-sankey-target-node--color-1 { fill: var(--viz-series-1); }
.viz-sankey-target-node--color-2 { fill: var(--viz-series-2); }
.viz-sankey-target-node--color-3 { fill: var(--viz-series-3); }
.viz-sankey-target-node--color-4 { fill: var(--viz-series-4); }
.viz-sankey-target-node--color-5 { fill: var(--viz-series-5); }
.viz-sankey-target-node--color-6 { fill: var(--viz-series-6); }
.viz-sankey-target-node--color-7 { fill: var(--viz-series-7); }

.viz-sankey-target-node--focus {
  fill: var(--data-focus);
  opacity: 0.92;
}

.viz-sankey-target-node--leftover {
  fill: var(--positive);
  opacity: 0.86;
}

.viz-sankey-target-node--shortfall {
  fill: var(--risk);
  opacity: 0.86;
}

.viz-sankey-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
}

.viz-sankey-label--source,
.viz-sankey-label--focus {
  fill: var(--text);
  font-weight: 650;
}

.viz-sankey-value {
  fill: var(--text-faint);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.viz-group-focus {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.viz-export {
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.viz-export-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}
.viz-export-head::-webkit-details-marker { display: none; }
.viz-export-head::after {
  content: "+";
  color: var(--text-faint);
  font-size: 12px;
}
.viz-export[open] .viz-export-head::after {
  content: "\2212";
}
.viz-export-head-text {
  display: flex;
  align-items: center;
  gap: 10px;
}

.viz-export-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.viz-export-title {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.viz-export-status {
  font-size: 11px;
  color: var(--data-focus);
}

.viz-export textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.4;
  padding: 8px;
}

@media (max-width: 760px) {
  .viz-summary {
    grid-template-columns: 1fr;
  }

  .viz-date-field {
    flex: 1 1 130px;
  }
}

.viz-drilldown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.viz-drilldown-list {
  display: flex;
  flex-direction: column;
}

.viz-drilldown-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 78px auto;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.viz-drilldown-date {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.viz-drilldown-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.viz-drilldown-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
