.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.view-tab {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
}

.view-tab:hover {
  background: var(--panel-alt);
}

.view-tab.active {
  background: var(--text);
  color: #fff;
}

.page-view {
  display: grid;
  gap: 16px;
}

.history-chart-wrap {
  display: grid;
  gap: 12px;
}

.history-chart {
  width: 100%;
  height: 320px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  cursor: crosshair;
}

.history-chart-grid {
  stroke: #d7e2ec;
  stroke-width: 1;
}

.history-chart-axis {
  fill: var(--muted);
  font-size: 12px;
  text-anchor: end;
}

.history-chart-axis-x {
  font-size: 11px;
}

.history-chart-area {
  fill: rgba(31, 111, 235, 0.12);
}

.history-chart-line {
  fill: none;
  stroke: #1f6feb;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 6px 10px rgba(31, 111, 235, 0.14));
}

.history-chart-dot {
  fill: #1f6feb;
  stroke: #ffffff;
  stroke-width: 2;
}

.history-chart-dot.subtle {
  fill: #8ab4f8;
}

.history-chart-dot.muted {
  fill: #8ab4f8;
  opacity: 0.78;
}

.history-chart-hit {
  fill: transparent;
  cursor: crosshair;
  pointer-events: all;
}

.history-chart-crosshair,
.history-chart-label-bg,
.history-chart-label-text,
.history-chart-tooltip-bg,
.history-chart-tooltip-text,
.history-chart-marker .history-chart-dot {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.history-chart-marker:hover .history-chart-crosshair,
.history-chart-marker:hover .history-chart-label-bg,
.history-chart-marker:hover .history-chart-label-text,
.history-chart-marker:hover .history-chart-tooltip-bg,
.history-chart-marker:hover .history-chart-tooltip-text,
.history-chart-marker:hover .history-chart-dot,
.history-chart-marker:focus .history-chart-crosshair,
.history-chart-marker:focus .history-chart-label-bg,
.history-chart-marker:focus .history-chart-label-text,
.history-chart-marker:focus .history-chart-tooltip-bg,
.history-chart-marker:focus .history-chart-tooltip-text,
.history-chart-marker:focus .history-chart-dot {
  opacity: 1;
}

.history-chart-marker:focus {
  outline: none;
}

.history-chart-crosshair {
  stroke: rgba(15, 23, 42, 0.42);
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

.history-chart-label-bg {
  fill: #1f6feb;
}

.history-chart-label-text {
  fill: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.history-chart-tooltip-bg {
  fill: #ffffff;
  stroke: #d7e2ec;
  stroke-width: 1;
  filter: drop-shadow(0 8px 16px rgba(15, 23, 42, 0.14));
}

.history-chart-tooltip-text {
  fill: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.history-chart-tooltip-text.muted {
  fill: var(--muted);
  font-weight: 600;
}

.history-chart-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.funding-stats-head {
  align-items: center;
}

.funding-stats-mode {
  display: inline-grid;
  grid-template-columns: repeat(2, 44px);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
}

.funding-stats-mode-btn {
  min-height: 32px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
}

.funding-stats-mode-btn.active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
  box-shadow: 0 2px 6px rgba(16, 32, 51, 0.08);
}

.funding-stats-toolbar {
  display: grid;
  grid-template-columns: 34px minmax(150px, max-content) 34px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.funding-stats-nav-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.funding-stats-nav-btn:hover,
.funding-stats-nav-btn:focus-visible {
  border-color: var(--line-strong);
  color: var(--text);
  outline: none;
}

.funding-stats-period-wrap {
  position: relative;
  display: inline-flex;
}

.funding-stats-period {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0;
}

.funding-stats-period:hover,
.funding-stats-period:focus-visible {
  background: var(--panel-alt);
  outline: none;
}

.funding-stats-period::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
}

.funding-stats-period-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 280px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(16, 32, 51, 0.16);
}

.funding-stats-period-popup.year-only {
  grid-template-columns: minmax(0, 1fr);
  min-width: 140px;
}

.funding-stats-option-list {
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
}

.funding-stats-option {
  min-height: 36px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.funding-stats-option:hover,
.funding-stats-option:focus-visible {
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.funding-stats-option.active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
  box-shadow: 0 2px 6px rgba(16, 32, 51, 0.08);
}

.funding-calendar-weekdays,
.funding-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.funding-calendar {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.funding-calendar-weekdays {
  background: var(--panel-alt);
}

.funding-calendar-weekdays span {
  padding: 9px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.funding-calendar-day {
  min-width: 0;
  min-height: 82px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.funding-calendar-day:nth-child(7n) {
  border-right: 0;
}

.funding-calendar-day.outside {
  background: var(--panel-alt);
}

.funding-calendar-day.positive {
  background: var(--accent-soft);
}

.funding-calendar-day.negative {
  background: var(--danger-soft);
}

.funding-calendar-date {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.funding-calendar-value,
.funding-year-month-value {
  min-width: 0;
  align-self: end;
  text-align: right;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.funding-calendar-value {
  align-self: center;
  text-align: center;
}

.funding-calendar-value.positive,
.funding-year-month-value.positive {
  color: var(--accent-strong);
}

.funding-calendar-value.negative,
.funding-year-month-value.negative {
  color: var(--danger);
}

.funding-calendar-value.zero,
.funding-calendar-value.no-data,
.funding-year-month-value.zero,
.funding-year-month-value.no-data {
  color: var(--muted);
}

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

.funding-year-month {
  min-width: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.funding-year-month-label {
  font-size: 13px;
  font-weight: 700;
}

.funding-year-month-days {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.funding-stats-footer {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  letter-spacing: 0;
}

.funding-stats-footer-value {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.funding-stats-footer-value.positive {
  color: var(--accent-strong);
}

.funding-stats-footer-value.negative {
  color: var(--danger);
}

@media (max-width: 720px) {
  .funding-stats-head {
    align-items: flex-start;
    gap: 10px;
  }

  .funding-calendar-day {
    min-height: 64px;
    gap: 4px;
    padding: 6px 4px;
  }

  .funding-calendar-weekdays span,
  .funding-calendar-date {
    font-size: 10px;
  }

  .funding-calendar-value {
    font-size: 9px;
    white-space: nowrap;
    overflow-wrap: normal;
  }

  .funding-year-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

:root[data-theme="dark"] .history-chart-crosshair {
  stroke: rgba(226, 232, 240, 0.46);
}

:root[data-theme="dark"] .history-chart-tooltip-bg {
  fill: var(--panel);
  stroke: var(--line-strong);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.22));
}
