/* Màn Tài chính (#/finance): kỳ tùy chọn, thẻ chỉ số, lãi lỗ, biểu đồ, Sổ thu chi, modal ghi thu / chi. */

.fin-range .fin-custom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.fin-custom label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-2); }
.fin-custom input[type=date] { width: auto; padding: 5px 8px; }
.fin-custom .form-error { flex-basis: 100%; margin: 0; }

.fin-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fin-auto { font-size: 11px; color: var(--muted); font-weight: 500; }

/* Lãi lỗ */
.fin-pl tr.pl-group td { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 14px; }
.fin-pl tr.pl-sub td { font-weight: 700; border-top: 1px dashed var(--line-strong); }
.fin-pl tr.pl-net td { font-weight: 800; background: var(--good-bg); border-top: 2px solid var(--accent-strong); }
.fin-pl tr.pl-net td:first-child { text-transform: uppercase; letter-spacing: 0.03em; }

/* Chi phí theo loại */
.fin-donut-wrap { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; align-items: center; }
.fin-donut { width: 100%; max-width: 170px; height: auto; display: block; }
.fin-donut circle { transition: opacity .12s; }
.fin-donut:hover circle { opacity: 0.6; }
.fin-donut circle:hover { opacity: 1; }
.fin-donut-total { font-size: 20px; font-weight: 800; fill: var(--ink); }
.fin-donut-sub { font-size: 11px; fill: var(--muted); }
.fin-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.fin-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 52px; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 8px; font-size: 13px; }
.fin-legend li:focus-visible, .fin-legend li:hover { background: var(--surface-2); outline: none; }
.fin-legend i { width: 12px; height: 12px; border-radius: 3px; }
.fin-split { margin-top: 16px; }
.fin-split .split-seg:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

/* Cột chồng */
.fin-chart .fin-avg { stroke: var(--ink-2); stroke-dasharray: 5 4; stroke-width: 1; }
.fin-chart .fin-avg-label { font-size: 11px; font-weight: 700; fill: var(--ink-2); }
.fin-chart .fin-col rect:not(.bar-hit) { transition: opacity .12s; }
.fin-chart svg:hover .fin-col rect:not(.bar-hit) { opacity: 0.55; }
.fin-chart svg .fin-col:hover rect:not(.bar-hit), .fin-chart .fin-col.is-selected rect:not(.bar-hit) { opacity: 1; }
.fin-chart .fin-col.is-click { cursor: pointer; outline: none; }
.fin-chart .fin-col.is-click:focus-visible .bar-hit, .fin-chart .fin-col.is-selected .bar-hit { fill: rgba(63, 143, 58, 0.12); }
.fin-day-panel { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }

/* 6 tháng */
.fin-months th[scope=row] { text-align: left; font-weight: 700; }

/* Sổ thu chi */
.fin-led-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.fin-cat-filter select { width: auto; min-width: 180px; padding: 6px 8px; }
.fin-ledger { list-style: none; margin: 0; padding: 0; }
.led-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.led-row:last-child { border-bottom: 0; }
.led-row.is-auto { background: var(--surface-2); }
.led-row.is-summary { border-left: 3px solid var(--line-strong); }
.fin-led-date { display: flex; flex-direction: column; line-height: 1.2; }
.fin-led-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fin-led-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fin-led-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.fin-row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* Sale: "Ghi chi phí" */
.fin-self-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 560px; }

/* Modal */
.modal.modal-wide { width: min(680px, 100%); }
.fin-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px; gap: 3px; justify-self: start; }
.seg-btn { border: 0; background: none; border-radius: 999px; padding: 6px 14px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg-btn.is-active { background: var(--ink); color: var(--surface); }
.fin-impact { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fin-choices { border: 0; margin: 0; padding: 0; min-width: 0; }
.fin-choices legend { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.fin-choice { position: relative; user-select: none; }
.fin-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.fin-choice:has(input:checked) { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.fin-choice:has(input:focus-visible) { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.fin-guide p { margin: 0 0 6px; }
.fin-warn { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--ink); }
.fin-meta { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.fin-meta legend { padding: 0 4px; }
.fin-meta .btn { align-self: flex-start; }

@media (max-width: 1100px) {
  .fin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .fin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .fin-legend { width: 100%; }
  .led-row { grid-template-columns: 48px minmax(0, 1fr); }
  .fin-led-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; }
  .fin-months .fin-hide-sm { display: none; }
  .fin-months thead { display: none; }
  .fin-months tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .fin-months th[scope=row], .fin-months td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 4px; }
  .fin-months td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; }
}
