/* Expenses, financial report and staff leave (module 50_expenses) */
:root { --ex-in: #2a78d6; --ex-out: #eb6834; }

.ex-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 16px; }
.ex-tabs .chip { padding: 6px 12px; }

details.ex-add > summary { list-style: none; color: var(--ink); }
details.ex-add > summary::-webkit-details-marker { display: none; }
details.ex-add > summary h2 { display: inline; margin: 0; color: var(--brand-2); }
details.ex-add[open] > summary { margin-bottom: 14px; }
details.ex-add { margin-top: 0; font-size: inherit; }

.ex-inline { flex-direction: row; align-items: center; gap: 8px; }
.ex-inline select, .ex-inline input { width: auto; }
.filters .ex-month { width: auto; }

/* grouped horizontal bars: collected vs expenses per month */
.legend i.ex-sw-in { background: var(--ex-in); }
.legend i.ex-sw-out { background: var(--ex-out); }
.ex-chart { display: flex; flex-direction: column; gap: 12px; }
.ex-crow { display: grid; grid-template-columns: 40px minmax(0, 1fr) 110px; gap: 10px; align-items: center; color: var(--ink); font-size: .86rem; }
.ex-crow:hover { text-decoration: none; }
.ex-crow:hover .ex-bar { filter: brightness(.92); }
.ex-clabel { font-weight: 600; color: var(--ink-2); }
.ex-pair { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ex-bar { display: block; height: 12px; border-radius: 0 4px 4px 0; min-width: 2px; }
.ex-in { background: var(--ex-in); }
.ex-out { background: var(--ex-out); }
.ex-cvals { display: flex; flex-direction: column; text-align: right; font-variant-numeric: tabular-nums; font-size: .8rem; line-height: 15px; color: var(--ink); }
@media (max-width: 480px) {
  .ex-crow { grid-template-columns: 34px minmax(0, 1fr) 92px; gap: 8px; }
  .ex-cvals { font-size: .74rem; }
}

/* expense categories */
.ex-cat-row { display: flex; gap: 12px; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid #eef1ef; }
.ex-cat-row:last-child { border-bottom: 0; }
.ex-cat-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 10px; align-items: end; flex: 1; min-width: 0; }
.ex-cat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ex-cat-row > form:last-child { padding-bottom: 8px; }
@media (max-width: 700px) {
  .ex-cat-row { flex-direction: column; align-items: stretch; }
  .ex-cat-form { grid-template-columns: 1fr; }
  .ex-cat-meta { flex-direction: row; justify-content: space-between; align-items: center; }
}

/* ledger */
.ex-ledger tr.ex-open td { background: #fafbfa; }

/* leave */
.ex-pad { padding: 0 18px 8px; }
.ex-sum { border-top: 4px solid var(--c); }
.ex-sum table.mini td, .ex-sum table.mini th { padding: 5px 4px; }
.ex-sum tr.ex-meter-row td { padding: 0 4px 6px; border-bottom: 0; }
.ex-ent input { width: 84px; min-height: 36px; padding: 6px 8px; text-align: right; }
.ex-ent th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 500; }
.ex-foot { padding-bottom: 16px; }
.ex-lcat { display: flex; gap: 10px; align-items: flex-end; padding: 10px 0; border-bottom: 1px solid #eef1ef; }
.ex-lcat-form { display: grid; grid-template-columns: 90px minmax(0, 1.2fr) minmax(0, 2fr) auto auto; gap: 10px; align-items: end; flex: 1; min-width: 0; }
.ex-lcat-form label.check { padding-bottom: 10px; white-space: nowrap; }
.ex-lcat > form:last-child { padding-bottom: 8px; }
.ex-lcat-new { padding-top: 14px; }
@media (max-width: 900px) {
  .ex-lcat { flex-direction: column; align-items: stretch; }
  .ex-lcat-form { grid-template-columns: 1fr 1fr; }
  .ex-lcat-form label:nth-of-type(3) { grid-column: 1 / -1; }
}

.ex-bal .tile b small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.ex-bal .meter { display: block; margin: 6px 0 4px; }
.ex-myleave li { align-items: flex-start; }
.ex-aff { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.ex-aff .chip { font-size: .76rem; padding: 2px 9px; }
.ex-st { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ex-affected td .badge { margin: 1px 0; }

.ex-tbal { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.ex-tbal > div { display: flex; flex-direction: column; padding: 10px 12px; background: #f6f8f7; border-radius: 10px; }
.ex-tbal b { font-size: 1.4rem; line-height: 1.2; font-variant-numeric: tabular-nums; }

.ex-dash .row.between h2 { margin: 0; }
.ex-dash .row.between, .ex-tcard .row.between { margin-bottom: 10px; }
.ex-tcard .row.between h2 { margin: 0; }
.tiles.ex-bal { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.page-head .actions .badge { align-self: center; }
.tiles.ex-tiles { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
@media (max-width: 480px) {
  .tiles.ex-tiles { gap: 10px; }
  .tiles.ex-tiles .tile b { font-size: 1.2rem; }
}

/* expense list as stacked rows on phones */
@media (max-width: 640px) {
  .ex-table thead { display: none; }
  .ex-table, .ex-table tbody, .ex-table tfoot { display: block; }
  .ex-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 12px 14px; border-bottom: 1px solid #eef1ef; }
  .ex-table td { display: block; padding: 0; border: 0; }
  .ex-table tbody tr:hover td { background: none; }
  .ex-table td:nth-child(3) { grid-column: 1; grid-row: 1; }
  .ex-table td:nth-child(7) { grid-column: 2; grid-row: 1; font-weight: 700; }
  .ex-table td:nth-child(1) { grid-column: 1; grid-row: 2; font-size: .82rem; color: var(--muted); }
  .ex-table td:nth-child(2) { grid-column: 2; grid-row: 2; text-align: right; color: var(--muted); }
  .ex-table td:nth-child(4) { grid-column: 1; grid-row: 3; }
  .ex-table td:nth-child(6) { grid-column: 2; grid-row: 3; text-align: right; }
  .ex-table td:nth-child(5) { grid-column: 1; grid-row: 4; color: var(--muted); }
  .ex-table td:nth-child(8) { grid-column: 2; grid-row: 4; text-align: right; }
  .ex-table td.empty { grid-column: 1 / -1; }
  .ex-table tfoot tr { display: flex; justify-content: space-between; }
  .ex-table tfoot td:last-child { display: none; }
}
