/* ============================================================
   Finance & Accounting OS — tab "Tổng hợp chi" (js/fa/pay-summary.js)

   Tiền tố .fap- cho MỌI lớp: workspace này dùng chung một trang với 12
   workspace khác, lớp trần kiểu .card/.kpi chắc chắn đụng nơi khác.
   Mọi thứ bọc trong .fap nên không rò ra ngoài tab.
   ============================================================ */

.fap {
  --fap-ink: #1B2A4A;
  --fap-mut: #64748b;
  --fap-line: #e5e7eb;
  --fap-soft: #f8fafc;
  padding: 14px 18px 34px;
  font-size: 13px;
  color: #334155;
}

/* ── Thanh công cụ ───────────────────────────────────────────── */
.fap-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 13px; }
.fap-seg-grp { display: flex; align-items: center; gap: 4px; }
.fap-btn {
  padding: 7px 13px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff;
  font-size: 13px; color: #334155; cursor: pointer; font-family: inherit; line-height: 1.3;
}
.fap-btn:hover { background: #f8fafc; border-color: #94a3b8; }
.fap-btn.is-on { background: var(--fap-ink); border-color: var(--fap-ink); color: #fff; font-weight: 700; }
.fap-btn:disabled { opacity: .55; cursor: default; }
.fap-inp {
  padding: 6px 9px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 13px; background: #fff; color: #0f172a; font-family: inherit;
}
.fap-lbl-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fap-mut); }
.fap-year { font-size: 15px; font-weight: 700; color: var(--fap-ink); min-width: 52px; text-align: center; }

/* ── Thẻ ─────────────────────────────────────────────────────── */
.fap-card {
  background: #fff; border: 1px solid var(--fap-line); border-radius: 12px;
  padding: 14px 16px 16px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.fap-card + .fap-card, .fap-kpis + .fap-card { margin-top: 12px; }
.fap-card-h {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin: 0 0 12px; font-size: 13px; font-weight: 700; color: var(--fap-ink); letter-spacing: .2px;
}
.fap-card-h small { font-weight: 500; font-size: 11.5px; color: var(--fap-mut); letter-spacing: 0; }
.fap-card-h small b { color: #475569; font-weight: 700; }

/* ── Hàng KPI ────────────────────────────────────────────────── */
.fap-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 13px; }
@media (max-width: 900px) { .fap-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fap-kpi {
  background: #fff; border: 1px solid var(--fap-line); border-left: 3px solid #cbd5e1;
  border-radius: 10px; padding: 10px 13px; min-width: 0;
}
.fap-kpi-l { font-size: 11px; font-weight: 600; color: var(--fap-mut); text-transform: uppercase; letter-spacing: .4px; }
.fap-kpi-v { font-size: 19px; font-weight: 700; color: var(--fap-ink); margin-top: 3px; line-height: 1.2; }
.fap-kpi-s { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.fap-kpi.is-tot  { border-left-color: var(--fap-ink); }
.fap-kpi.is-paid { border-left-color: #16a34a; } .fap-kpi.is-paid .fap-kpi-v { color: #15803d; }
.fap-kpi.is-plan { border-left-color: #2563eb; } .fap-kpi.is-plan .fap-kpi-v { color: #1d4ed8; }
.fap-kpi.is-def  { border-left-color: #f97316; } .fap-kpi.is-def  .fap-kpi-v { color: #c2410c; }

/* ── Lưới 2 cột cho biểu đồ ──────────────────────────────────── */
.fap-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 1180px) { .fap-grid2 { grid-template-columns: minmax(0, 1fr); } }

/* ── Bảng tổng hợp (pivot) ───────────────────────────────────── */
.fap-tblwrap { overflow: auto; border: 1px solid var(--fap-line); border-radius: 10px; background: #fff; }
.fap-tblwrap.is-wide { max-height: calc(100vh - 430px); }
table.fap-tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
table.fap-tbl th, table.fap-tbl td { padding: 6px 9px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
table.fap-tbl thead th {
  position: sticky; top: 0; z-index: 2; background: var(--fap-ink); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; border-bottom: none; text-align: right;
}
table.fap-tbl thead tr:last-child th { top: 27px; background: #2c3f66; font-weight: 600; font-size: 10.5px; }
table.fap-tbl td.num, table.fap-tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.fap-tbl td.fap-lbl, table.fap-tbl th.fap-lbl {
  position: sticky; left: 0; z-index: 1; text-align: left; background: #fff;
  min-width: 200px; box-shadow: 1px 0 0 var(--fap-line);
}
table.fap-tbl thead th.fap-lbl { background: var(--fap-ink); z-index: 3; }
table.fap-tbl thead tr:last-child th.fap-lbl { background: #2c3f66; }
table.fap-tbl tbody tr:hover td { background: #f6f9ff; }
table.fap-tbl tbody tr:hover td.fap-lbl { background: #eef4ff; }
.fap-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 7px; vertical-align: -1px; }
.fap-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 99px;
  font-size: 10px; font-weight: 700; color: #b45309; background: #fef3c7;
}
td.fap-zero { color: #cbd5e1; }
td.fap-hit { cursor: pointer; font-weight: 600; color: var(--fap-ink); }
td.fap-hit:hover { background: #dbeafe !important; }
td.fap-rowtot { font-weight: 700; color: var(--fap-ink); background: var(--fap-soft); }
td.fap-pct { color: var(--fap-mut); font-size: 11.5px; }
th.fap-we, td.fap-we { background: #fbfcfe; }
th.fap-today, td.fap-today { background: #fff7ed; }
table.fap-tbl thead th.fap-today { background: #9a3412; }
tr.fap-total td { background: #f1f5f9; font-weight: 700; color: var(--fap-ink); border-top: 2px solid #cbd5e1; }
tr.fap-total td.fap-lbl { background: #e8edf5; }

.fap-note { font-size: 11.5px; color: var(--fap-mut); margin-top: 8px; line-height: 1.55; }
.fap-note b { color: #475569; }

/* ── Khối biểu đồ dùng chung ─────────────────────────────────── */
.fap-chart-empty {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed #d7dee8; border-radius: 10px;
  color: #94a3b8; font-size: 12.5px; background: var(--fap-soft);
}
.fap-svgwrap { overflow-x: auto; }
.fap-ax  { font-size: 10.5px; fill: #94a3b8; font-family: inherit; }
.fap-ax.is-flag { fill: #c2410c; font-weight: 700; }
.fap-bartot { font-size: 10px; fill: var(--fap-mut); font-weight: 600; font-family: inherit; }
.fap-bar, .fap-slice { transition: opacity .12s; }
.fap-bar:hover, .fap-slice:hover { opacity: .78; }

/* ── Donut + chú thích ───────────────────────────────────────── */
.fap-donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.fap-donut { position: relative; flex: 0 0 auto; }
.fap-donut-mid {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.fap-donut-t { font-size: 9.5px; font-weight: 700; color: #94a3b8; letter-spacing: .6px; }
.fap-donut-v { font-size: 20px; font-weight: 700; color: var(--fap-ink); line-height: 1.15; }
.fap-donut-n { font-size: 10.5px; color: #94a3b8; }
.fap-legend { flex: 1 1 240px; min-width: 230px; display: flex; flex-direction: column; gap: 1px; }
.fap-lg-row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 44px;
  align-items: center; gap: 8px; padding: 3px 5px; border-radius: 6px; font-size: 12px;
}
.fap-lg-row:nth-child(odd) { background: var(--fap-soft); }
.fap-lg-dot { width: 9px; height: 9px; border-radius: 3px; }
.fap-lg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #475569; }
.fap-lg-val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--fap-ink); }
.fap-lg-pct { font-variant-numeric: tabular-nums; text-align: right; color: var(--fap-mut); font-size: 11.5px; }

/* ── Thanh xếp chồng ─────────────────────────────────────────── */
.fap-stack { display: flex; height: 26px; border-radius: 7px; overflow: hidden; background: #eef2f7; }
.fap-stack.is-thin { height: 14px; border-radius: 5px; }
.fap-seg { display: flex; align-items: center; justify-content: center; min-width: 2px; }
.fap-seg span { font-size: 10.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .18); }
.fap-keys { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 9px; }
.fap-key { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--fap-mut); }
.fap-key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.fap-key b { color: var(--fap-ink); font-variant-numeric: tabular-nums; }

.fap-sub { margin-top: 14px; border-top: 1px solid #f1f5f9; padding-top: 11px; }
.fap-sub-h { font-size: 11.5px; font-weight: 700; color: var(--fap-mut); margin-bottom: 8px; }
.fap-sub-h b { color: #c2410c; }
.fap-prow { display: grid; grid-template-columns: 140px minmax(0, 1fr) 100px; align-items: center; gap: 10px; margin-top: 6px; }
.fap-prow-l { font-size: 11.5px; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fap-prow-v { font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; color: var(--fap-ink); font-weight: 600; }
