.cashflow-ledger-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  padding: 5px 11px;
  border: 1px solid rgba(11, 122, 117, .2);
  border-radius: 999px;
  background: #eaf8f6;
  color: #08736f;
  font-size: 13px;
  font-weight: 800;
  vertical-align: middle;
}

#cashflowPage .cashflow-controls-toggle {
  flex: 0 0 auto;
  min-width: 58px !important;
  margin-left: auto;
  white-space: nowrap;
}

#cashflowPage.cashflow-controls-hidden .cashflow-one-line-filter,
#cashflowPage.cashflow-controls-hidden .cashflow-top-grid {
  display: none !important;
}

.cashflow-ledger-admin-box {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) minmax(160px, .8fr) auto minmax(160px, .8fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 13px 14px;
  border: 1px solid rgba(11, 122, 117, .16);
  border-radius: 16px;
  background: linear-gradient(135deg, #f0fbf9, #fff);
}

.cashflow-ledger-admin-copy {
  display: grid;
  gap: 3px;
  align-self: center;
}

.cashflow-ledger-admin-copy strong { color: #0b7a75; }
.cashflow-ledger-admin-copy span { font-weight: 800; color: #163c3a; }
.cashflow-ledger-admin-copy small { color: #64748b; line-height: 1.45; }

.cashflow-ledger-admin-box label {
  display: grid;
  gap: 5px;
  color: #526273;
  font-size: 12px;
  font-weight: 800;
}

.cashflow-ledger-admin-box input,
.cashflow-ledger-admin-box select {
  height: 36px;
  min-width: 0;
  border: 1px solid #d5e6e4;
  border-radius: 11px;
  padding: 7px 10px;
  background: #fff;
}

#cashflowPage .cashflow-excel-table {
  min-width: 1250px !important;
}

#cashflowPage .cashflow-excel-table th:nth-child(1),
#cashflowPage .cashflow-excel-table td:nth-child(1) { width: 40px !important; text-align: center !important; }
#cashflowPage .cashflow-excel-table th:nth-child(2),
#cashflowPage .cashflow-excel-table td:nth-child(2) { width: 48px !important; text-align: center !important; }
#cashflowPage .cashflow-excel-table th:nth-child(3),
#cashflowPage .cashflow-excel-table td:nth-child(3) { width: 112px !important; }
#cashflowPage .cashflow-excel-table th:nth-child(4),
#cashflowPage .cashflow-excel-table td:nth-child(4) { width: 430px !important; font-weight: 400 !important; }
#cashflowPage .cashflow-excel-table th:nth-child(5),
#cashflowPage .cashflow-excel-table td:nth-child(5) { width: 84px !important; text-align: center !important; }
#cashflowPage .cashflow-excel-table th:nth-child(6),
#cashflowPage .cashflow-excel-table td:nth-child(6),
#cashflowPage .cashflow-excel-table th:nth-child(7),
#cashflowPage .cashflow-excel-table td:nth-child(7),
#cashflowPage .cashflow-excel-table th:nth-child(8),
#cashflowPage .cashflow-excel-table td:nth-child(8) { width: 92px !important; text-align: right !important; }
#cashflowPage .cashflow-excel-table th:nth-child(9),
#cashflowPage .cashflow-excel-table td:nth-child(9) { width: 136px !important; text-align: left !important; }
#cashflowPage .cashflow-excel-table th:nth-child(10),
#cashflowPage .cashflow-excel-table td:nth-child(10) { width: 58px !important; text-align: center !important; }
#cashflowPage .cashflow-excel-table th:nth-child(11),
#cashflowPage .cashflow-excel-table td:nth-child(11) { width: 72px !important; text-align: center !important; }
#cashflowPage .cashflow-excel-table th:nth-child(12),
#cashflowPage .cashflow-excel-table td:nth-child(12) {
  width: 122px !important;
  text-align: center !important;
}

#cashflowPage .cashflow-excel-table tbody tr:nth-child(odd):not(.cashflow-new-row):not(.cashflow-group-row) td:nth-child(5) {
  background: rgba(248, 250, 252, .82) !important;
}

#cashflowPage .cashflow-excel-table tbody tr:nth-child(even):not(.cashflow-new-row):not(.cashflow-group-row) td:nth-child(5) {
  background: rgba(255, 255, 255, .9) !important;
}

#cashflowPage .cashflow-excel-table td:nth-child(6) { background: rgba(254, 226, 226, .42) !important; }
#cashflowPage .cashflow-excel-table td:nth-child(7) { background: rgba(220, 252, 231, .48) !important; }
#cashflowPage .cashflow-excel-table td:nth-child(8) { background: rgba(219, 234, 254, .48) !important; }

#cashflowPage .cashflow-select-th,
#cashflowPage .cashflow-select-cell {
  padding-inline: 5px !important;
  overflow: visible !important;
}

#cashflowPage .cashflow-select-cell,
#cashflowPage .cashflow-seq-cell {
  cursor: pointer;
  user-select: none;
}

#cashflowPage #cashflowRows.cashflow-selection-dragging,
#cashflowPage #cashflowRows.cashflow-selection-dragging * {
  cursor: crosshair !important;
  user-select: none !important;
}

#cashflowPage .cashflow-select-th input,
#cashflowPage .cashflow-select-cell input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #0b7a75;
  cursor: pointer;
  vertical-align: middle;
}

#cashflowPage .cashflow-select-cell input:disabled {
  cursor: not-allowed;
  opacity: .35;
}

#cashflowPage .cashflow-excel-table tr.row-selected td:not(:nth-child(6)):not(:nth-child(7)):not(:nth-child(8)) {
  background: #e9f8f5 !important;
}

#cashflowPage .cashflow-group-row td {
  height: 46px !important;
  max-height: none !important;
  background: linear-gradient(180deg, #e5f7f4, #d5efeb) !important;
  border-top: 2px solid rgba(11, 122, 117, .38) !important;
  border-bottom: 2px solid rgba(11, 122, 117, .32) !important;
  color: #0b4d49;
  font-weight: 700;
}

#cashflowPage .cashflow-group-row td:first-child {
  box-shadow: inset 5px 0 0 #0b7a75;
}

#cashflowPage .cashflow-group-row.row-selected td {
  background: linear-gradient(180deg, #def5f0, #d3eee8) !important;
}

#cashflowPage .cashflow-group-project {
  padding-block: 3px !important;
  white-space: normal !important;
}

#cashflowPage .cashflow-group-toggle {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: auto auto;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #0b625e;
  text-align: left;
  cursor: pointer;
}

#cashflowPage .cashflow-group-badge {
  grid-row: 1 / 3;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 24px;
  border-radius: 8px;
  background: #0b7a75;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

#cashflowPage .cashflow-group-toggle strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 18px;
}

#cashflowPage .cashflow-group-toggle small {
  color: #5b7775;
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
}

#cashflowPage .cashflow-group-child-row td:nth-child(2) {
  color: #5a7775;
  font-size: 12px !important;
}

#cashflowPage .cashflow-group-child-row .cashflow-main-project {
  position: relative;
  padding-left: 24px !important;
}

#cashflowPage .cashflow-group-child-row .cashflow-main-project::before {
  position: absolute;
  left: 8px;
  top: 50%;
  width: 10px;
  height: 8px;
  border-left: 2px solid #84bdb7;
  border-bottom: 2px solid #84bdb7;
  content: "";
  transform: translateY(-70%);
}

#cashflowPage .cashflow-unmerge-btn {
  height: 26px;
  min-width: 42px;
  padding: 0 8px;
  border: 1px solid rgba(190, 24, 93, .22);
  border-radius: 9px;
  background: rgba(255, 255, 255, .78);
  color: #a61b52;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

#cashflowPage .cashflow-unmerge-btn:hover,
#cashflowPage .cashflow-unmerge-btn:focus-visible {
  border-color: rgba(190, 24, 93, .4);
  background: #fff1f5;
  outline: none;
}

.cashflow-group-modal-card {
  display: flex !important;
  flex-direction: column !important;
  width: min(1320px, calc(100vw - 36px)) !important;
  max-width: 1320px !important;
  height: min(820px, calc(100vh - 40px)) !important;
  max-height: min(820px, calc(100vh - 40px)) !important;
  border: 2px solid rgba(11, 122, 117, .28);
  overflow: hidden !important;
}

.cashflow-group-modal-head,
.cashflow-group-modal-actions {
  flex: 0 0 auto;
}

.cashflow-group-modal-head > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.cashflow-group-name-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-width: 0;
}

.cashflow-group-name-form strong {
  overflow-wrap: anywhere;
}

.cashflow-group-name-form .cashflow-group-name-input {
  width: 420px;
  max-width: 100%;
  min-width: 0;
  height: 36px;
  padding: 5px 10px;
  border: 1px solid #0b7a75;
  border-radius: 8px;
  background: #fff;
  color: #0b4d49;
  font-size: 18px;
}

.cashflow-group-name-form button {
  flex: 0 0 auto;
}

.cashflow-group-modal-head strong {
  color: #0b4d49;
  font-size: 20px;
}

.cashflow-group-modal-head small {
  color: #64748b;
  font-weight: 700;
}

.cashflow-group-modal-kicker {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: #0b7a75;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.cashflow-group-modal-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  border: 1px solid rgba(11, 122, 117, .16);
  border-radius: 10px;
  overflow-x: auto !important;
  overflow-y: scroll !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.cashflow-group-modal-table {
  width: 100%;
  min-width: 1080px;
  table-layout: fixed;
}

.cashflow-group-modal-table .cashflow-group-col-seq { width: 46px; }
.cashflow-group-modal-table .cashflow-group-col-date { width: 126px; }
.cashflow-group-modal-table .cashflow-group-col-project { width: 36%; }
.cashflow-group-modal-table .cashflow-group-col-category { width: 88px; }
.cashflow-group-modal-table .cashflow-group-col-income,
.cashflow-group-modal-table .cashflow-group-col-expense { width: 92px; }
.cashflow-group-modal-table .cashflow-group-col-note { width: 16%; }
.cashflow-group-modal-table .cashflow-group-col-operator { width: 78px; }
.cashflow-group-modal-table .cashflow-group-col-actions { width: 116px; }

.cashflow-group-modal-table th,
.cashflow-group-modal-table td {
  padding-inline: 7px !important;
}

.cashflow-group-modal-table th:first-child,
.cashflow-group-modal-table td:first-child,
.cashflow-group-modal-table th:nth-child(4),
.cashflow-group-modal-table td:nth-child(4),
.cashflow-group-modal-table th:nth-child(8),
.cashflow-group-modal-table td:nth-child(8),
.cashflow-group-modal-table th:last-child,
.cashflow-group-modal-table td:last-child {
  text-align: center;
  white-space: nowrap;
}

.cashflow-group-modal-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #e5f7f4;
  color: #0b4d49;
}

.cashflow-group-modal-table tbody tr:nth-child(even) td {
  background: #f5fbfa;
}

.cashflow-group-modal-project {
  white-space: normal !important;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.cashflow-group-modal-table .cashflow-edit-cell {
  cursor: text;
}

.cashflow-group-modal-table .cashflow-edit-cell:hover {
  background: #e8f7f5 !important;
  box-shadow: inset 0 0 0 1px rgba(11, 122, 117, .28);
}

.cashflow-group-modal-table .cashflow-cell-input {
  width: 100%;
  min-width: 0;
}

.cashflow-group-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.cashflow-group-edit-btn {
  min-width: 44px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(11, 122, 117, .3);
  border-radius: 8px;
  background: #edf9f7;
  color: #08736f;
  font-weight: 800;
  cursor: pointer;
}

.cashflow-group-edit-btn:hover:not(:disabled) {
  border-color: #0b7a75;
  background: #dff5f1;
}

.cashflow-group-edit-btn:disabled {
  cursor: not-allowed;
  opacity: .4;
}

.cashflow-detach-btn {
  min-width: 48px;
  height: 28px;
  border: 1px solid rgba(180, 83, 9, .32);
  border-radius: 8px;
  background: #fff7ed;
  color: #b45309;
  font-weight: 800;
  cursor: pointer;
}

.cashflow-detach-btn:hover:not(:disabled) {
  border-color: #b45309;
  background: #ffedd5;
}

.cashflow-detach-btn:disabled {
  cursor: not-allowed;
  opacity: .4;
}

.cashflow-group-modal-table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.cashflow-group-modal-table-wrap::-webkit-scrollbar-track {
  border-radius: 999px;
  background: #e5efee;
}

.cashflow-group-modal-table-wrap::-webkit-scrollbar-thumb {
  border: 2px solid #e5efee;
  border-radius: 999px;
  background: #6aa9a4;
}

.cashflow-group-modal-table-wrap::-webkit-scrollbar-thumb:hover {
  background: #377f7a;
}

.cashflow-group-modal-table-wrap:focus-visible {
  outline: 2px solid rgba(11, 122, 117, .4);
  outline-offset: 2px;
}

.cashflow-group-modal-actions {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cashflow-group-modal-actions .muted {
  margin-right: auto;
  text-align: left;
}

#cashflowPage .cashflow-batch-action:disabled {
  cursor: not-allowed;
  opacity: .48;
}

#cashflowPage .cashflow-one-line-filter {
  grid-template-columns: minmax(210px, 1.7fr) minmax(136px, .9fr) minmax(136px, .9fr) minmax(112px, .75fr) minmax(88px, .6fr) minmax(104px, .75fr) minmax(92px, .62fr) minmax(88px, .6fr) repeat(6, auto) !important;
}

#cashflowPage .cashflow-action-cell {
  padding-inline: 6px !important;
}

#cashflowPage .cashflow-action-buttons {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#cashflowPage .cashflow-order-btn {
  min-width: 44px !important;
  height: 26px !important;
  min-height: 26px !important;
  padding: 0 9px !important;
  border: 1px solid rgba(11, 122, 117, .24) !important;
  border-radius: 9px !important;
  background: #edf9f7 !important;
  color: #08736f !important;
  font: 700 12px/1 "Microsoft YaHei", sans-serif !important;
  cursor: pointer;
  box-shadow: none !important;
}

#cashflowPage .cashflow-order-btn:hover,
#cashflowPage .cashflow-order-btn:focus-visible {
  border-color: rgba(11, 122, 117, .48) !important;
  background: #dff5f1 !important;
  outline: none;
}

#cashflowPage .cashflow-delete-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  min-height: 26px !important;
  padding: 0 !important;
  border: 1px solid rgba(11, 122, 117, .14) !important;
  border-radius: 9px !important;
  background: rgba(255, 255, 255, .7) !important;
  color: rgba(11, 122, 117, .62) !important;
  font: 400 17px/1 Arial, "Microsoft YaHei", sans-serif !important;
  cursor: pointer;
  opacity: .58;
  box-shadow: none !important;
  transition: opacity .15s ease, background-color .15s ease, border-color .15s ease, transform .15s ease !important;
}

#cashflowPage .cashflow-delete-btn:hover,
#cashflowPage .cashflow-delete-btn:focus-visible {
  opacity: 1;
  color: #0b7a75 !important;
  border-color: rgba(11, 122, 117, .28) !important;
  background: #f2faf9 !important;
  transform: translateY(-1px);
  outline: none;
}

#cashflowPage .cashflow-delete-btn:disabled {
  opacity: .22;
  cursor: not-allowed;
  transform: none;
}

/* Keep complete amounts visible beside the pie, including seven-digit totals. */
#cashflowPage .cashflow-chart-card.cashflow-chart-combo,
#cashflowPage .cashflow-chart-card.cashflow-chart-combo.cashflow-rank-wide {
  grid-template-columns: max-content minmax(0, 1fr) !important;
}

#cashflowPage .cashflow-pie-block {
  width: max-content !important;
  min-width: 0 !important;
  max-width: none !important;
}

#cashflowPage #cashflowPieLegend {
  flex: 0 0 auto !important;
  min-width: max-content !important;
  max-width: none !important;
  white-space: nowrap !important;
}

#cashflowPage #cashflowPieLegend > span {
  white-space: nowrap !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
}

@media (max-width: 980px) {
  #cashflowPage .cashflow-chart-card.cashflow-chart-combo,
  #cashflowPage .cashflow-chart-card.cashflow-chart-combo.cashflow-rank-wide {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 1450px) {
  .cashflow-ledger-admin-box { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
  .cashflow-ledger-admin-copy { grid-column: 1 / -1; }
  #cashflowPage .cashflow-one-line-filter { grid-template-columns: repeat(4, minmax(120px, 1fr)) !important; }
}

@media (max-width: 760px) {
  .cashflow-ledger-badge { display: flex; width: max-content; margin: 8px 0 0; }
  .cashflow-ledger-admin-box { grid-template-columns: 1fr; }
  .cashflow-ledger-admin-copy { grid-column: auto; }
}
