/* Tally & Day Book (School ERP 3.2.82). Scoped to [data-gap-module="tally"].
   The page is drawn with the ERP's own pieces — the page heading, metric
   cards, panels, "Add" cards in numbered sections, the register filter and
   search bars, the figure strip and the record pills — so this file holds only
   what those do not: amounts in colour, long text that wraps inside its
   column, the closing sheet, the ledger-mapping boxes and the printed
   registers. Colours come from the ERP tokens, which dark mode redefines. The
   print tables and the dialogs live outside the page root (appended to <body>)
   and carry their own tally- prefix instead. */

/* The drawer takes every pane; the stacks and groups they came from are left empty. */
[data-gap-module="tally"] .workflow-stack:empty,
[data-gap-module="tally"] > .drawer-group:empty { display: none; }
[data-gap-module="tally"] > .drawer-group { min-width: 0; }

/* Filter bars: a day or a range, what to show, and whose money it was. */
[data-gap-module="tally"] .tally-filter input[type="date"] { min-width: 150px; max-width: 100%; min-height: 36px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 650; }
[data-gap-module="tally"] .tally-filter-buttons { display: flex; flex-wrap: wrap; align-items: flex-end; align-self: end; gap: 6px; min-width: 0; }
[data-gap-module="tally"] .tally-contents { display: contents; }

/* A register's totals (the ERP's figure strip) and its notices. */
[data-gap-module="tally"] .tally-strip { margin-top: 14px; }
[data-gap-module="tally"] .tally-strip em { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 600; }
[data-gap-module="tally"] [data-tally-slot] > .form-note,
[data-gap-module="tally"] .tally-preview > .form-note { margin: 0 0 12px; }
[data-gap-module="tally"] [data-tally-list] > .form-note:first-child { margin-top: 14px; }
[data-gap-module="tally"] .tally-saved-note { margin-top: 12px; }
[data-gap-module="tally"] .tally-preview { margin-top: 16px; min-width: 0; }
[data-gap-module="tally"] .form-note.tally-note-danger { border-left-color: var(--danger); color: var(--ink); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
[data-gap-module="tally"] .form-note.tally-note-warning { border-left-color: var(--warning); color: var(--ink); background: color-mix(in srgb, var(--warning) 9%, var(--surface)); }
[data-gap-module="tally"] .form-note.tally-note-success { border-left-color: var(--success); color: var(--ink); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
[data-gap-module="tally"] .section-grid .register-subhead { margin: 0 0 8px; }
/* On a phone the ERP's section grid is one "1fr" column, which would grow to
   the widest table in it; the grid's own boxes stay the column's width and the
   tables scroll inside their frames. */
[data-gap-module="tally"] .form-sections .section-grid > * { min-width: 0; max-width: 100%; }
[data-gap-module="tally"] [data-tally-slot] > .register-subhead:first-child { margin-top: 0; }

/* Two summaries side by side where there is room, one above the other where there is not. */
[data-gap-module="tally"] .tally-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 0 16px; align-items: start; }
[data-gap-module="tally"] .tally-pair > div { min-width: 0; }
/* The ERP gives every table a 760px floor so a wide register scrolls in its
   frame; these small tables are drawn at their own width instead. */
[data-gap-module="tally"] .tally-pair .data-table,
[data-gap-module="tally"] .tally-sheet,
[data-gap-module="tally"] .tally-denominations,
[data-gap-module="tally"] .tally-map { min-width: 0; }

/* Money in and out, and the rows that are not money any more. */
[data-gap-module="tally"] .tally-amount-in { color: var(--success); font-weight: 750; font-variant-numeric: tabular-nums; }
[data-gap-module="tally"] .tally-amount-out { color: var(--danger); font-weight: 750; font-variant-numeric: tabular-nums; }
[data-gap-module="tally"] tr.tally-voided td { color: var(--muted); }
[data-gap-module="tally"] tr.tally-voided .tally-amount-in,
[data-gap-module="tally"] tr.tally-voided .tally-amount-out { color: var(--muted); text-decoration: line-through; }
[data-gap-module="tally"] tr.tally-reversal td { background: color-mix(in srgb, var(--warning) 7%, var(--surface)); }

/* Long text wraps inside its own column; the register scrolls inside its frame, never the page. */
[data-gap-module="tally"] .tally-wrap { display: block; min-width: 160px; max-width: 340px; white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
[data-gap-module="tally"] .tally-narration { min-width: 220px; max-width: 420px; font-size: 12px; }
[data-gap-module="tally"] .tally-file { font-size: 11.5px; word-break: break-all; }
[data-gap-module="tally"] .tally-action { margin: 0 0 6px; color: var(--ink); font-size: 12px; }
[data-gap-module="tally"] .tally-action--done { color: var(--success); }
[data-gap-module="tally"] .tally-lines { display: grid; gap: 2px; min-width: 220px; max-width: 360px; white-space: normal; }
[data-gap-module="tally"] .tally-line { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; line-height: 1.5; }
[data-gap-module="tally"] .tally-line span { min-width: 0; overflow-wrap: anywhere; }
[data-gap-module="tally"] .tally-line b { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The cash closing sheet and the notes counted. */
[data-gap-module="tally"] .tally-sheet,
[data-gap-module="tally"] .tally-denominations { width: 100%; border-collapse: collapse; background: var(--surface); font-variant-numeric: tabular-nums; }
[data-gap-module="tally"] .tally-sheet th,
[data-gap-module="tally"] .tally-sheet td,
[data-gap-module="tally"] .tally-denominations th,
[data-gap-module="tally"] .tally-denominations td { padding: 9px 12px; border-top: 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 13px; text-align: left; vertical-align: middle; }
/* Row labels, not column headings: the ERP's heading case and ground do not apply. */
[data-gap-module="tally"] .tally-sheet th,
[data-gap-module="tally"] .tally-denominations tbody th,
[data-gap-module="tally"] .tally-denominations tfoot th { background: var(--surface); text-transform: none; letter-spacing: normal; }
[data-gap-module="tally"] .tally-sheet th { font-weight: 650; overflow-wrap: anywhere; }
[data-gap-module="tally"] .tally-sheet td,
[data-gap-module="tally"] .tally-denominations td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
[data-gap-module="tally"] .tally-sheet th small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 500; }
[data-gap-module="tally"] .tally-sheet-total th,
[data-gap-module="tally"] .tally-sheet-total td { border-top: 2px solid var(--ink); font-weight: 800; background: color-mix(in srgb, var(--brand) 5%, var(--surface)); }
[data-gap-module="tally"] .tally-sheet-short td { color: var(--danger); }
[data-gap-module="tally"] .tally-denominations thead th { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
[data-gap-module="tally"] .tally-denominations tfoot th,
[data-gap-module="tally"] .tally-denominations tfoot td { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 800; }
[data-gap-module="tally"] .form-sections .section-grid .tally-denominations td input[type="number"]:not([type="checkbox"]) { width: 100%; max-width: 140px; min-width: 70px; min-height: 38px; padding: 6px 10px; text-align: right; }
[data-gap-module="tally"] .tally-difference { color: var(--success); border-left-color: var(--success); font-size: 13px; font-weight: 750; }
[data-gap-module="tally"] .tally-difference--off { color: var(--danger); border-left-color: var(--danger); }

/* Ledger mapping: a box and a group per head. */
[data-gap-module="tally"] .tally-map td { vertical-align: middle; }
[data-gap-module="tally"] .form-sections .section-grid .tally-map td input[data-tally-map-ledger]:not([type="checkbox"]),
[data-gap-module="tally"] .form-sections .section-grid .tally-map td select[data-tally-map-group] { min-width: 150px; min-height: 38px; padding: 6px 10px; font-size: 12.5px; }
[data-gap-module="tally"] .tally-map input::placeholder { color: var(--muted); opacity: .75; }

@media (max-width: 620px) {
  [data-gap-module="tally"] .tally-filter input[type="date"] { width: 100%; min-width: 0; }
  [data-gap-module="tally"] .tally-filter-buttons { flex: 1 1 100%; }
  [data-gap-module="tally"] .tally-wrap { min-width: 140px; max-width: 260px; }
  [data-gap-module="tally"] .tally-sheet th,
  [data-gap-module="tally"] .tally-sheet td,
  [data-gap-module="tally"] .tally-denominations th,
  [data-gap-module="tally"] .tally-denominations td { padding: 8px 9px; font-size: 12.5px; }
}

/* Dialogs appended to <body>. */
.tally-dialog .form-note { margin-bottom: 4px; }

/* Printed day book, closing sheet, bank book, bounced list and vouchers, inside
   the ERP's shared document. Every table is the full width of the A4 page with
   its columns set in percentages, so nothing runs off the paper: long names
   and references wrap, and the wide registers are set a size smaller. */
.tally-print h3 { margin: 5mm 0 2mm; font-size: 10.5pt; break-after: avoid; }
.tally-print-table { width: 100%; min-width: 0; max-width: 100%; table-layout: fixed; border-collapse: collapse; margin: 0 0 3mm; font-size: 8.5pt; line-height: 1.35; font-variant-numeric: tabular-nums; }
.tally-print-table.is-compact { font-size: 7.5pt; }
.tally-print-table th,
.tally-print-table td { padding: 1.3mm 1.6mm; border: 1px solid var(--line); color: var(--ink); text-align: left; vertical-align: top; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.tally-print-table.is-compact th,
.tally-print-table.is-compact td { padding: 1mm 1.2mm; }
.tally-print-table .is-money { text-align: right; white-space: nowrap; overflow-wrap: normal; word-break: normal; }
.tally-print-table thead { display: table-header-group; }
.tally-print-table tr { break-inside: avoid; }
.tally-print-table th { font-size: inherit; font-weight: 800; text-transform: none; letter-spacing: normal; background: color-mix(in srgb, var(--brand) 6%, var(--surface)); }
.tally-print-table tfoot td { font-weight: 800; border-top: 2px solid var(--ink); }
.tally-print-signs { display: flex; justify-content: space-between; gap: 10mm; margin-top: 14mm; break-inside: avoid; }
.tally-print-signs div { width: 58mm; max-width: 45%; text-align: center; }
.tally-print-signs i { display: block; height: 0; margin-bottom: 2mm; border-top: 1px solid var(--ink); }
.tally-print-signs span { font-size: 9pt; font-weight: 700; }
@media print {
  .tally-print-table th { background: transparent; }
  .tally-print-table th, .tally-print-table td { border-color: #000; color: #000; }
}
