/* 拾光 · 收支 */

.cashflow-view {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.cashflow-heading {
  margin-bottom: 0;
}

.cashflow-year-switch {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}

.cashflow-year-btn {
  border: 0;
}

.cashflow-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.cashflow-stat {
  position: relative;
  overflow: hidden;
  padding: 18px 19px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.06));
  border-radius: 20px;
  background: var(--card, rgba(255, 255, 255, 0.72));
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(0, 0, 0, 0.03));
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

.cashflow-stat::after {
  content: '';
  position: absolute;
  right: -38px;
  top: -46px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--flow-tone, rgba(10, 132, 255, 0.13)), transparent 68%);
  pointer-events: none;
}

.cashflow-stat--income {
  --flow-tone: rgba(48, 209, 88, 0.13);
}

.cashflow-stat--expense {
  --flow-tone: rgba(255, 159, 10, 0.13);
}

.cashflow-stat--net {
  --flow-tone: rgba(10, 132, 255, 0.13);
}

.cashflow-stat--rate {
  --flow-tone: rgba(191, 90, 242, 0.13);
}

.cashflow-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 13px;
  border-radius: 11px;
  color: var(--blue, #0a84ff);
  background: rgba(10, 132, 255, 0.09);
}

.cashflow-stat--income .cashflow-stat-icon {
  color: var(--green, #30d158);
  background: rgba(48, 209, 88, 0.1);
}

.cashflow-stat--expense .cashflow-stat-icon {
  color: var(--orange, #ff9f0a);
  background: rgba(255, 159, 10, 0.1);
}

.cashflow-stat--rate .cashflow-stat-icon {
  color: var(--purple, #bf5af2);
  background: rgba(191, 90, 242, 0.1);
}

.cashflow-stat-label {
  margin: 0;
  font-size: 10.5px;
  color: var(--text-3, #8a8a90);
}

.cashflow-stat-value {
  margin: 3px 0 4px;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text, #1d1d1f);
}

.cashflow-stat-value.is-positive {
  color: var(--green, #30d158);
}

.cashflow-stat-value.is-negative {
  color: var(--pink, #ff375f);
}

.cashflow-stat-sub {
  margin: 0;
  font-size: 10px;
  color: var(--text-3, #8a8a90);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------- 两栏账本 */
.cashflow-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.cashflow-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 360px;
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.cashflow-column::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  opacity: 0.72;
}

.cashflow-column--income::before {
  background: linear-gradient(90deg, var(--green, #30d158), var(--teal, #64d2ff));
}

.cashflow-column--expense::before {
  background: linear-gradient(90deg, var(--orange, #ff9f0a), var(--pink, #ff375f));
}

.cashflow-column-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.cashflow-column-total {
  margin: 2px 0 4px;
  font-size: 32px;
  line-height: 1.05;
  font-weight: 660;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.cashflow-column-sub {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-3, #8a8a90);
}

.cashflow-cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 10px 0 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.055));
}

.cashflow-cat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(120, 120, 128, 0.055);
  font-size: 9.5px;
  color: var(--text-2, #55555a);
}

.cashflow-cat i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.cashflow-cat strong {
  font-size: 9.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cashflow-cat small {
  color: var(--text-3, #8a8a90);
}

.cashflow-record-list {
  flex: 1;
  min-height: 0;
  max-height: 430px;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

.cashflow-record {
  display: grid;
  grid-template-columns: 31px 6px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 9px 6px;
  margin: 0 -6px;
  border-radius: 10px;
  transition: background 160ms ease;
}

.cashflow-record:hover {
  background: rgba(120, 120, 128, 0.055);
}

.cashflow-record-month {
  font-size: 10.5px;
  font-weight: 560;
  color: var(--text-2, #55555a);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cashflow-record-month small {
  margin-left: 1px;
  font-size: 8.5px;
  color: var(--text-3, #8a8a90);
}

.cashflow-record-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.cashflow-record-main {
  min-width: 0;
}

.cashflow-record-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cashflow-record-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 560;
}

.cashflow-record-title .tag {
  flex: 0 0 auto;
}

.cashflow-record-note {
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9.5px;
  color: var(--text-3, #8a8a90);
}

.cashflow-record-amount {
  font-size: 12px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cashflow-record-amount.is-income {
  color: var(--green, #30d158);
}

.cashflow-record-amount.is-expense {
  color: var(--text, #1d1d1f);
}

.cashflow-record-actions {
  display: inline-flex;
  align-items: center;
  opacity: 0.38;
  transition: opacity 160ms ease;
}

.cashflow-record:hover .cashflow-record-actions,
.cashflow-record-actions:focus-within {
  opacity: 1;
}

.cashflow-icon-btn {
  width: 25px !important;
  height: 25px !important;
  color: var(--text-3, #8a8a90);
}

.cashflow-icon-btn--danger:hover {
  color: var(--pink, #ff375f);
  background: rgba(255, 55, 95, 0.08);
}

.cashflow-column .empty-state {
  padding: 34px 12px;
}

/* ---------------------------------------------------------- 底部 */
.cashflow-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(310px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.cashflow-chart-card,
.cashflow-history {
  padding: 22px;
  min-width: 0;
}

.cashflow-chart-wrap {
  height: 198px;
  margin: 0 -4px;
}

.cashflow-chart-wrap .chart-svg {
  height: 198px;
}

.cashflow-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 9.5px;
  color: var(--text-3, #8a8a90);
}

.cashflow-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cashflow-legend i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.cashflow-history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cashflow-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 7px;
  margin: 0 -7px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease;
}

.cashflow-history-row:hover {
  background: rgba(120, 120, 128, 0.055);
}

.cashflow-history-row.is-active {
  background: rgba(10, 132, 255, 0.065);
}

.cashflow-history-year {
  flex: 0 0 38px;
  font-size: 11.5px;
  font-weight: 620;
  color: var(--text-2, #55555a);
  font-variant-numeric: tabular-nums;
}

.cashflow-history-metrics {
  display: flex;
  flex: 1;
  gap: 14px;
  min-width: 0;
}

.cashflow-history-metrics span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cashflow-history-metrics small {
  font-size: 8.5px;
  color: var(--text-3, #8a8a90);
}

.cashflow-history-metrics strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cashflow-history-metrics .is-positive {
  color: var(--green, #30d158);
}

.cashflow-history-metrics .is-negative {
  color: var(--pink, #ff375f);
}

.cashflow-history-rate {
  flex: 0 0 42px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cashflow-history-rate small {
  font-size: 8.5px;
  font-weight: 400;
  color: var(--text-3, #8a8a90);
}

.cashflow-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px 22px;
  font-size: 9.5px;
  color: var(--text-3, #8a8a90);
}

/* ---------------------------------------------------------- 响应式 */
@media (max-width: 1260px) {
  .cashflow-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cashflow-bottom-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1000px) {
  .cashflow-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .cashflow-column {
    min-height: 280px;
  }

  .cashflow-record-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .cashflow-view {
    gap: 16px;
  }

  .cashflow-heading .page-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .cashflow-year-switch {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .cashflow-year-btn {
    flex: 0 0 auto;
  }

  .cashflow-heading .page-actions .btn {
    flex: 1;
  }

  .cashflow-stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cashflow-column,
  .cashflow-chart-card,
  .cashflow-history {
    padding: 17px;
  }

  .cashflow-column-head {
    flex-direction: column;
  }

  .cashflow-column-head .btn {
    align-self: flex-start;
  }

  .cashflow-column-total {
    font-size: 28px;
  }

  .cashflow-record {
    grid-template-columns: 27px 6px minmax(0, 1fr) auto;
  }

  .cashflow-record-actions {
    grid-column: 2 / 5;
    grid-row: 2;
    justify-content: flex-end;
    opacity: 1;
    display: inline-flex;
  }

  .cashflow-record-amount {
    font-size: 11px;
  }

  .cashflow-chart-wrap,
  .cashflow-chart-wrap .chart-svg {
    height: 170px;
  }

  .cashflow-history-metrics {
    gap: 8px;
  }

  .cashflow-history-rate {
    flex-basis: 36px;
  }
}

@media (max-width: 460px) {
  .cashflow-record {
    grid-template-columns: 26px 6px minmax(0, 1fr);
  }

  .cashflow-record-amount {
    grid-column: 3;
    grid-row: 2;
    justify-self: start;
  }

  .cashflow-record-actions {
    grid-column: 2 / 4;
    grid-row: 3;
  }

  .cashflow-history-metrics {
    gap: 6px;
  }

  .cashflow-history-metrics small {
    font-size: 8px;
  }

  .cashflow-history-metrics strong {
    font-size: 9.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cashflow-record,
  .cashflow-history-row {
    transition: none !important;
  }
}
