/* ============================================================
   Income & Spending (js/modules/finance.js): the list, the
   transaction editor's receipt box, the bank-statement review, the
   Payroll Expense breakdown and the print-friendly accountant report
   (the app's PDF; Print → Save as PDF).
   ============================================================ */

/* ---------- Amounts ---------- */
.fin-in { color: var(--green); }
.fin-out { color: var(--red); }
.fin-unknown { color: var(--text-dim); }
.fin-amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Filters ---------- */
.fin-range { display: flex; max-width: 100%; }
.fin-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fin-dates .field-label { font-size: 0.85rem; }
.fin-type-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.fin-type-label { font-weight: 600; color: var(--ink); }
.fin-type-row .select { min-width: 150px; }

/* ---------- Category rows ---------- */
.fin-cat { min-height: 46px; }
.fin-cat .row-title { font-weight: 520; }
.fin-cat .row-trail-main { color: var(--text-dim); font-weight: 560; }

/* ---------- Notes under a section ---------- */
.fin-notes { display: flex; flex-direction: column; gap: 6px; }
.fin-notes > p { margin: 0; }
.fin-warn { display: flex; gap: 6px; align-items: flex-start; color: var(--orange); }
.fin-warn .icon { color: var(--ink); margin-top: 2px; flex-shrink: 0; }
.fin-group-notes { padding: 0 6px; font-size: 0.85rem; color: var(--text-dim); }

.fin-more { display: flex; justify-content: center; padding: 12px 16px; }

/* ---------- Transaction detail ---------- */
.fin-detail-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 16px; }

/* ---------- Editor: category and receipt ---------- */
.fin-category { display: flex; flex-direction: column; gap: 8px; }
.fin-receipt {
  display: flex; flex-direction: column; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius-ui); background: rgba(255, 255, 255, 0.75); border: 1px solid var(--line);
}
.fin-receipt-line { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 560; }
.fin-receipt-line .icon { flex-shrink: 0; }
.fin-receipt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fin-receipt-problem { color: var(--red); font-size: 0.85rem; margin: 0; }
.fin-receipt-note { color: var(--text-dim); font-size: 0.85rem; margin: 0; }
.fin-spinner { width: 16px; height: 16px; border-width: 2px; flex-shrink: 0; }

/* ---------- Export choices ---------- */
.fin-export-summary { color: var(--text-dim); font-size: 0.9rem; margin: 0; }

/* ---------- Bank statement import ---------- */
.fin-imp { display: flex; flex-direction: column; gap: 16px; }
.fin-imp-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 18px 8px 8px; color: var(--ink); }
.fin-imp-empty .empty-title { font-weight: 700; font-size: 1.05rem; }
.fin-imp-empty p { max-width: 34rem; margin: 0; }
.fin-imp-reading { display: inline-flex; align-items: center; gap: 10px; color: var(--text-dim); }
.fin-imp-head { display: flex; flex-direction: column; gap: 10px; }
.fin-imp-file { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fin-imp-file-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; color: var(--ink); }
.fin-imp-file-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-imp-note { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: 0.82rem; color: var(--text-dim); }
.fin-imp-note .icon { color: var(--ink); flex-shrink: 0; margin-top: 1px; }
.fin-imp-summary { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.fin-imp-summary .right { text-align: right; }
.fin-imp-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; }
.fin-imp-row.is-off { opacity: 0.55; }
.fin-imp-check { flex-shrink: 0; color: var(--ink); padding: 2px; border-radius: 50%; display: flex; }
.fin-imp-main { flex: 1; min-width: 0; }
.fin-imp-desc {
  font-size: 0.92rem; color: var(--ink); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.fin-imp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-dim); margin-top: 3px; }
.fin-imp-cat {
  color: var(--ink); font-size: 0.8rem; text-decoration: underline; text-underline-offset: 2px;
  padding: 0; border-radius: 4px; text-align: left; overflow-wrap: anywhere;
}
.fin-imp-amt { flex-shrink: 0; font-weight: 650; font-size: 0.92rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Payroll Expense ---------- */
.fin-run { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; }
.fin-run-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.fin-run-title { font-weight: 600; color: var(--ink); }
.fin-run-total { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-run-sub { font-size: 0.84rem; color: var(--text-dim); }
.fin-run-flag { display: flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--orange); }
.fin-run-flag .icon { color: var(--ink); }

/* ---------- Accountant report (screen = the paper; print = the PDF) ---------- */
.fin-report-hint { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 0.88rem; }
.fin-report {
  background: #fff; color: #000; border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 36px 40px 28px; font-size: 13px; line-height: 1.4;
  width: 100%; max-width: 980px; margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, var(--font);
}
.fin-r-head { border-bottom: 1.5px solid #000; padding-bottom: 10px; margin-bottom: 16px; }
.fin-r-company { font-size: 22px; font-weight: 700; line-height: 1.25; }
.fin-r-title { font-size: 15px; font-weight: 600; color: #444; margin: 2px 0 8px; }
.fin-r-detail { font-size: 12px; }
.fin-r-fine { font-size: 12px; color: #777; margin-top: 4px; }
.fin-r-boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.fin-r-box { background: #f9f9f9; border: 0.75px solid #d1d1d1; border-radius: 6px; padding: 8px 10px; min-width: 0; }
.fin-r-box-label { font-size: 10px; font-weight: 600; color: #444; }
.fin-r-box-value { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fin-r-box-detail { font-size: 11px; color: #777; }
.fin-r-section { margin-bottom: 22px; }
.fin-r-h { font-size: 15px; font-weight: 600; margin: 0 0 5px; }
.fin-r-empty { font-size: 12px; color: #777; margin: 0; }
.fin-r-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fin-rtable { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.fin-rtable th {
  background: #ebebeb; color: #444; font-size: 9.5px; font-weight: 600; text-transform: uppercase;
  text-align: left; padding: 4px 5px; vertical-align: bottom;
}
.fin-rtable td { padding: 4px 5px; vertical-align: top; overflow-wrap: anywhere; }
.fin-rtable tbody tr:nth-child(even) td { background: #f6f6f6; }
.fin-rtable tfoot td { font-weight: 600; border-top: 1px solid #000; }
.fin-rtable .r { text-align: right; }
.fin-rtable .c { text-align: center; }
.fin-rtable .nw { white-space: nowrap; }
.fin-rtable .ml { white-space: pre-line; }
.fin-rtable .memo { min-width: 9em; }
.fin-r-notes ul { list-style: none; padding: 0; margin: 0; }
.fin-r-notes li { font-size: 11.5px; color: #444; margin-bottom: 3px; }
.fin-r-foot { margin-top: 18px; padding-top: 6px; border-top: 0.5px solid #d1d1d1; font-size: 10px; color: #777; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .fin-range { width: 100%; }
  .fin-range .segmented { width: 100%; }
  .fin-range .seg { flex: 1 1 auto; padding-left: 8px; padding-right: 8px; }
  .fin-dates { grid-template-columns: 1fr; }
  .fin-type-row .select { min-width: 0; max-width: 60%; }
  .fin-report { padding: 20px 16px; border-radius: var(--radius-ui); }
  .fin-r-boxes { grid-template-columns: 1fr; }
  .fin-r-company { font-size: 19px; }
}

/* ---------- Print: just the report, on US Letter ---------- */
@media print {
  @page { size: letter portrait; margin: 0.55in; }
  .fin-report-page > .page-head, .fin-report-hint { display: none !important; }
  .fin-report {
    border: 0; box-shadow: none; border-radius: 0; padding: 0; font-size: 9.5pt; max-width: none;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .fin-report * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .fin-r-boxes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fin-r-company { font-size: 17pt; }
  .fin-report .fin-r-wrap { overflow: visible; }
  .fin-rtable { font-size: 8.5pt; }
  .fin-rtable th { font-size: 7pt; }
  .fin-rtable thead { display: table-header-group; }
  .fin-rtable tfoot { display: table-row-group; }
  .fin-rtable tr, .fin-r-box, .fin-r-notes li { break-inside: avoid; page-break-inside: avoid; }
  .fin-r-h { break-after: avoid; page-break-after: avoid; }
}
