.record-meta { color: #687486; font-size: .8rem; font-weight: 400; overflow-wrap: anywhere; }
.record-amount { font-size: 1.08rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.record-person { padding: .3rem .55rem; border-radius: .5rem; background: #edf3fc; color: #24548c; font-size: .8rem; overflow-wrap: anywhere; }
.record-state { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .6rem; border-radius: .5rem; font-size: .78rem; font-weight: 600; line-height: 1.4; }
.record-state-ok { background: #e8f6ef; color: #17643c; }
.record-state-surplus { background: #e8f1ff; color: #2455a0; }
.record-state-shortfall, .record-state-cancelled { background: #ffeded; color: #a92637; }
.record-cancelled-amount { color: #8c6670; text-decoration: line-through; }
.record-description { white-space: pre-wrap; overflow-wrap: anywhere; }
.history-page > .row > .col-12 > .d-flex { flex-wrap: wrap; gap: .75rem; }
.history-page td { vertical-align: middle; }
.history-page .records-table-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .75rem; margin-bottom: 1rem; }
.history-page .records-table-tools > * { margin: 0; }
.sale-products { max-width: 360px; }
.sale-products summary { cursor: pointer; min-height: 44px; padding: .25rem 0; overflow-wrap: anywhere; }
.sale-products summary::marker { color: #0d6efd; }
.sale-products li { overflow-wrap: anywhere; }
.sales-ranking { max-height: 640px; overflow-y: auto; }
.ranking-entry { display: flex; gap: .75rem; padding: 1rem; border-bottom: 1px solid #e7ecf2; }
.ranking-position { display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px; border-radius: .5rem; background: #edf3fc; color: #24548c; font-weight: 700; }
.ranking-entry:first-child { background: #f4f8ff; }
.ranking-entry:first-child .ranking-position { background: #0d6efd; color: white; }
.ranking-content { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ranking-metrics { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; font-size: .875rem; }
.ranking-bar { height: 5px; margin: .5rem 0; border-radius: 99px; background: #e8edf4; overflow: hidden; }
.ranking-bar span { display: block; height: 100%; background: #568ce5; border-radius: inherit; }
.report-detail-scroll { max-height: 640px; overflow-y: auto; }
.report-sidebar .expense-records, .report-sidebar .expense-records tbody { display: block; width: 100%; }
.report-sidebar .expense-records thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.report-sidebar .expense-records tr { display: grid; grid-template-columns: minmax(0, 1fr); padding: .75rem; border-bottom: 1px solid #e7ecf2; }
.report-sidebar .expense-records td { border: 0; padding: .25rem !important; overflow-wrap: anywhere; }
.report-sidebar .expense-records td:last-child { text-align: left !important; }
.dark-mode .record-meta { color: #b4bfcc; }
.dark-mode .record-person, .dark-mode .ranking-position { background: #22334b; color: #accbff; }
.dark-mode .record-state-ok { background: #173e30; color: #95e1b9; }
.dark-mode .record-state-surplus { background: #203757; color: #aecbff; }
.dark-mode .record-state-shortfall, .dark-mode .record-state-cancelled { background: #4b2630; color: #ffc1cb; }
.dark-mode .ranking-entry:first-child { background: #1c2d43; }
.dark-mode .ranking-entry, .dark-mode .report-sidebar .expense-records tr { border-color: #39414c; }
.dark-mode .ranking-bar { background: #39414c; }

@media (max-width: 767.98px) {
    .history-page h2, .history-page h3 { font-size: 1.35rem; }
    .history-page > .row > .col-12 > .d-flex > .d-flex { width: 100%; }
    .history-page .records-table-tools { align-items: stretch; }
    .history-page .records-table-tools .dt-buttons { display: flex; flex-wrap: wrap; gap: .375rem; }
    .history-page .records-table-tools .dt-buttons > .btn { flex: 1; }
    .history-page .dataTables_wrapper .dataTables_filter, .history-page .dataTables_wrapper .dataTables_length { width: 100%; text-align: left; }
    .history-page .dataTables_wrapper .dataTables_filter label { display: block; white-space: normal; }
    .history-page .dataTables_wrapper .dataTables_filter input { display: block; width: 100%; margin: .25rem 0 0; min-height: 44px; font-size: 16px; }
    .history-page .dataTables_paginate .pagination { flex-wrap: wrap; justify-content: center; gap: .25rem; }
    .history-page .dataTables_info { white-space: normal; font-size: .8rem; }
    .history-page .dataTables_paginate .page-link { min-width: 40px; min-height: 44px; display: grid; place-items: center; border-radius: .375rem; }
    .history-page > .row > .col-12 > .card > .card-body { padding: .75rem; }
    .history-page .cash-history-table td:nth-child(5), .history-page .cash-history-table td:nth-child(7) { order: 3; background: #f5f8fd; }
    .history-page .cash-history-table td:nth-child(8) { order: 4; }
    .history-page .cash-history-table td:nth-child(3) { order: 5; }
    .history-page .cash-history-table td:nth-child(4), .history-page .cash-history-table td:nth-child(6) { order: 6; }
    .history-page .cash-history-table td:nth-child(9) { order: 7; }
    .history-page .cash-history-table td:nth-child(1)::before, .history-page .cash-history-table td:nth-child(2)::before { display: none; }
    .sale-ticket-table td:first-child::before { display: none; }
    .sale-ticket-table td:first-child { font-size: 1rem; }
    .sale-ticket-table td:nth-child(3) { grid-column: 1 / -1; order: 5; border-top: 1px solid #e7ecf2; }
    .professional-history .sale-ticket-table td:nth-child(6) { order: 3; }
    .professional-history .sale-ticket-table td:nth-child(5) { order: 4; }
    .professional-history .sale-ticket-table td:nth-child(4) { display: none; }
    .sales-history-page .sale-ticket-table td:nth-child(5) { order: 3; }
    .sales-history-page .sale-ticket-table td:nth-child(4) { order: 4; }
    .sales-history-page .sale-ticket-table td:nth-child(6) { order: 6; grid-column: 1 / -1; }
    .sale-ticket-table td:last-child .btn-group { display: flex; width: 100%; gap: .5rem; }
    .sale-ticket-table td:last-child .btn-group > * { flex: 1; border-radius: .375rem; }
    .sales-history-page .card-body > .row { row-gap: .75rem; }
    .sale-products { max-width: none; }
    .expense-records td:nth-child(3) { grid-column: 1 / -1; }
    .expense-records td:last-child { grid-column: 1 / -1; text-align: left !important; background: #fff5f5; }
    .report-sidebar .expense-records td { grid-column: 1 / -1; }
    .report-sidebar .records-table-wrap { overflow: visible; }
    .professional-history .row-cols-md-5, .business-reports .row-cols-md-5 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .professional-history .row-cols-md-5 > .col, .business-reports .row-cols-md-5 > .col { width: 100%; min-width: 0; }
    .history-page .card-title { overflow-wrap: anywhere; }
    .dark-mode .history-page .cash-history-table td:nth-child(5), .dark-mode .history-page .cash-history-table td:nth-child(7) { background: #233247; }
    .dark-mode .expense-records td:last-child { background: #39242b; }
}

@media print {
    .sales-ranking, .report-detail-scroll { max-height: none; overflow: visible; }
    .record-state { border: 1px solid currentColor; }
}
