/* Webacc UI v2 - Billing section (billing/*.cfm and resolution/resolution.cfm).
   Loaded by v2/head_v2.cfm after theme.css, only when Request.uiVersion is v2.
   Every selector is scoped to body.v2-billing (plus body.v2-pg-<page>), a class those pages add
   only in v2, so the classic UI never sees any of this. Colours come from the theme.css tokens. */

/* ---------- page frame ---------- */
body.v2-billing .content-header,
body.v2-billing .content{max-width:1700px;margin-left:auto;margin-right:auto}
/* the pages carry style="padding:12px" or a .paddingc 40px gutter: normalise to the theme rhythm */
body.v2-billing .content{padding:12px 24px 32px!important}
body.v2-billing .content-header{display:flex;align-items:flex-end;justify-content:space-between;flex-wrap:wrap;gap:10px 24px;padding:22px 24px 8px;text-align:left!important}
body.v2-billing .content-header+br{display:none}
body.v2-billing .v2-page-title{flex:1 1 320px;min-width:0}
body.v2-billing .content-header h5,
body.v2-billing .content-header h6{margin:0}
body.v2-billing .content-header h6{font-size:1rem;font-weight:700;color:var(--v2-text-2)}
body.v2-billing .v2-page-desc{margin:4px 0 0;font-size:.84rem;color:var(--v2-text-2);max-width:72ch}
body.v2-billing .content-header .paddingr{padding:0}
/* month picker that lives in the header of the monthly reports */
body.v2-billing .content-header .col-md-2{flex:0 0 auto;width:auto;max-width:none;padding:0;position:static}
body.v2-billing .content-header .form-group{margin:0}
body.v2-billing .content-header .input-group{min-width:250px;flex-wrap:nowrap;border-radius:var(--v2-radius-xs);box-shadow:var(--v2-shadow-sm)}
body.v2-billing .content-header .input-group .form-control{float:none;font-weight:600}
/* the filter cards sit in a col-md-10: let them use the full width like the list pages */
body.v2-billing .content>.row>.col-md-10{flex:0 0 100%;max-width:100%;position:static}
@media (max-width:991px){
  body.v2-billing .content{padding-left:14px!important;padding-right:14px!important}
  body.v2-billing .content-header{padding-left:14px;padding-right:14px}
}

/* ---------- cards ---------- */
body.v2-billing .card-primary>.card-header.v2-toolbar{background:var(--v2-surface);color:var(--v2-text);border-bottom:1px solid var(--v2-border);display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:12px 20px}
body.v2-billing .card-outline>.card-header{display:flex;align-items:center;gap:8px;padding:12px 20px;font-size:.74rem;font-weight:800;text-transform:uppercase;letter-spacing:.1em;color:var(--v2-text-2)}
body.v2-billing .card-outline>.card-header i{color:var(--v2-primary)}
body.v2-billing .v2-push{margin-left:auto}
body.v2-billing .v2-empty{padding:28px 20px;text-align:center;color:var(--v2-muted);font-size:.9rem}

/* ---------- filter forms (#filterForm on the select / print / ledger pages) ---------- */
body.v2-billing #filterForm>div{padding:20px 20px 8px!important}
body.v2-billing #filterForm .row{padding-left:0!important;padding-right:0!important;align-items:flex-end}
body.v2-billing #filterForm .form-group{margin-bottom:16px}
body.v2-billing #filterForm label{display:block;margin:0 0 6px;padding:0;font-size:.72rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--v2-text-2)}
body.v2-billing #filterForm select[multiple]{height:280px;padding:6px}
body.v2-billing #filterForm select[multiple] option{padding:6px 10px;border-radius:6px}
body.v2-billing #filterForm .input-group.input-group-sm{display:block;padding-top:6px;font-size:.84rem;line-height:1.9;color:var(--v2-text-2)}
body.v2-billing #filterForm .input-group.input-group-sm b{color:var(--v2-text)}
body.v2-billing #filterForm input[type="radio"]{accent-color:var(--v2-primary);width:15px;height:15px;vertical-align:-2px;margin-right:2px}
body.v2-billing #filterForm .invalid-feedback{font-size:.75rem}

/* personal ledger member picker: the page's own <style> floats two 45% boxes with a 10% arrow column */
body.v2-billing .subject-info-box-1,
body.v2-billing .subject-info-box-2{float:none;width:auto;flex:1 1 280px;padding:0 7.5px}
body.v2-billing .subject-info-box-1 select,
body.v2-billing .subject-info-box-2 select{height:280px;padding:6px}
body.v2-billing .subject-info-box-1 option,
body.v2-billing .subject-info-box-2 option{padding:6px 10px;border-radius:6px}
body.v2-billing .subject-info-box-1 option:hover,
body.v2-billing .subject-info-box-2 option:hover{background:var(--v2-primary-soft)}
body.v2-billing .subject-info-arrows{float:none;width:auto;flex:0 0 auto;display:flex;flex-direction:column;justify-content:center;gap:8px;padding:26px 8px 0!important}
body.v2-billing .subject-info-arrows br{display:none}
body.v2-billing .subject-info-arrows input{width:44px;margin:0;font-family:var(--v2-mono);font-weight:600}
@media (max-width:767px){
  body.v2-billing .subject-info-arrows{flex-direction:row;flex-basis:100%;justify-content:center;padding:0 0 12px!important}
}

/* ---------- action rows ----------
   The v1 markup separates buttons with &nbsp; runs and <br>s, so the row collapses them with
   font-size:0 and spaces the buttons with margins instead of relying on the whitespace. */
body.v2-billing .v2-bl-actions{display:flex;flex-wrap:wrap;align-items:center;font-size:0;line-height:0}
body.v2-billing .v2-bl-actions>*{font-size:.8rem;line-height:1.5;margin:0 8px 0 0}
body.v2-billing .v2-bl-actions>br{display:none}
body.v2-billing .v2-bl-actions>.v2-push{margin-left:auto;margin-right:0}
body.v2-billing #filterForm .form-group.v2-bl-actions{margin-bottom:16px;row-gap:8px}
body.v2-billing #filterForm .v2-form-foot{margin-top:4px;padding:16px 0 8px!important;border-top:1px solid var(--v2-border)}
body.v2-billing .v2-card-actions{padding:12px 20px;border-top:1px solid var(--v2-border);background:var(--v2-surface-2);animation:v2-fade .4s ease both}
body.v2-billing .v2-card-actions>*{margin:4px 8px 4px 0}
body.v2-billing .v2-card-actions>.v2-push{margin-left:auto;margin-right:0}
body.v2-billing .v2-card-actions .btn-info{background:var(--v2-surface);border-color:var(--v2-border-strong);color:var(--v2-text-2);box-shadow:none}
body.v2-billing .v2-card-actions .btn-info:hover{color:var(--v2-primary);border-color:var(--v2-primary)}
/* the v1 forms colour every action green: give the main action the primary colour and make
   edit / delete / reset secondary so the hierarchy reads at a glance */
body.v2-billing #creatNew,body.v2-billing #creatNewExist,body.v2-billing #View{background:var(--v2-primary);border-color:var(--v2-primary);color:#fff;box-shadow:0 8px 18px -10px rgba(var(--v2-primary-rgb),.8)}
body.v2-billing #creatNew:hover,body.v2-billing #creatNewExist:hover,body.v2-billing #View:hover{background:var(--v2-primary-600);border-color:var(--v2-primary-600)}
body.v2-billing #Edit{background:var(--v2-surface);border-color:var(--v2-primary);color:var(--v2-primary);box-shadow:none}
body.v2-billing #Edit:hover{background:var(--v2-primary);color:#fff}
body.v2-billing #DeleteExist,body.v2-billing #Delete{background:var(--v2-surface);border-color:var(--v2-danger);color:var(--v2-danger);box-shadow:none}
body.v2-billing #DeleteExist:hover,body.v2-billing #Delete:hover{background:var(--v2-danger);color:#fff}
body.v2-billing #Reset{background:var(--v2-surface);border-color:var(--v2-border-strong);color:var(--v2-text-2);box-shadow:none}
body.v2-billing #Reset:hover{background:var(--v2-surface-2);color:var(--v2-text)}

/* ---------- list tables (DataTables pages) ---------- */
body.v2-billing .table td .btn.btn-sm{padding:.25rem .55rem;line-height:1.3}
body.v2-billing .table td a+a{margin-left:4px}
body.v2-pg-resolution #listTable td:last-child{white-space:nowrap}
body.v2-pg-suspense #listTable td:nth-child(6){text-align:right;font-family:var(--v2-mono);font-variant-numeric:tabular-nums}
body.v2-pg-suspense #listTable tr.sm{cursor:pointer}
/* explicitly right-aligned amount cells (print bill, receipt statement) */
body.v2-billing td[align="right"],body.v2-billing th[align="right"],
body.v2-billing td[style*="text-align: right"],body.v2-billing td[style*="text-align:right"],
body.v2-billing th[style*="text-align right"],body.v2-billing th[style*="text-align:right"]{text-align:right!important;font-family:var(--v2-mono);font-variant-numeric:tabular-nums}

/* ---------- report tables (bill summary, monthly reports, personal ledger) ----------
   v1 renders them inside a card-body with an inline 700px scroller and centred text. */
body.v2-billing .card-body[style*="overflow"]{height:auto!important;max-height:76vh;padding:0!important;text-align:left!important}
body.v2-billing .card-body[style*="overflow"]>br{display:none}
body.v2-billing .card-body[style*="overflow"] .table{margin:0;border:0;border-radius:0;font-size:.82rem;white-space:nowrap}
body.v2-billing .card-body[style*="overflow"] .table th,
body.v2-billing .card-body[style*="overflow"] .table td{padding:8px 12px}
body.v2-billing .card-body[style*="overflow"] thead tr:first-child th{position:sticky;top:0;z-index:2;background:var(--v2-surface-2);box-shadow:inset 0 -1px 0 var(--v2-border)}
/* the v1 markup keeps the data rows and the total row inside <thead>: only the first row is a real header */
body.v2-billing .card-body[style*="overflow"] thead tr+tr th{font-size:.82rem;text-transform:none;letter-spacing:0;color:var(--v2-text);background:var(--v2-surface-2);border-top:2px solid var(--v2-border-strong)!important}
body.v2-billing .card-body[style*="overflow"] th:nth-child(n+3),
body.v2-billing .card-body[style*="overflow"] td:nth-child(n+3),
body.v2-billing .card-body[style*="overflow"] th[colspan]~th{text-align:right;font-family:var(--v2-mono);font-variant-numeric:tabular-nums}
body.v2-billing .card-body[style*="overflow"] thead tr:first-child th:nth-child(n+3){font-family:var(--v2-font)}
body.v2-billing .card-body[style*="overflow"] td:first-child{font-weight:600}
body.v2-billing .card-body[style*="overflow"] td[align="left"]{text-align:left}
/* the ledger keeps its edit bar and actions inside the scroller, so it must not be height-capped */
body.v2-pg-personal-ledger .card-body[style*="overflow"]{max-height:none}

/* personal ledger inline edit (billing_ledger_edit.js injects its own hard-coloured <style>;
   these higher-specificity rules swap those colours for tokens so dark mode works) */
body.v2-billing .pl-edit-table td.pl-editable:hover{outline-color:var(--v2-primary)}
body.v2-billing .pl-edit-table td.pl-typed{background:color-mix(in srgb,var(--v2-warning) 22%,var(--v2-surface))!important}
body.v2-billing .pl-edit-table td.pl-cascade{background:color-mix(in srgb,var(--v2-info) 16%,var(--v2-surface))!important}
body.v2-billing .pl-edit-table td.pl-repair{background:color-mix(in srgb,var(--v2-warning) 36%,var(--v2-surface))!important}
body.v2-billing .pl-edit-table .pl-changed{color:var(--v2-primary-600)}
body.v2-billing .pl-edit-table .pl-input{font-family:var(--v2-mono);border:1px solid var(--v2-primary);border-radius:6px;background:var(--v2-surface);color:var(--v2-text)}
body.v2-billing .pl-edit-table .pl-err{background:var(--v2-surface);border-color:var(--v2-danger);color:var(--v2-danger);border-radius:8px;box-shadow:var(--v2-shadow)}
body.v2-billing .pl-edit-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;margin:0;padding:12px 20px;border-top:1px solid var(--v2-border);background:var(--v2-surface-2);text-align:left}
body.v2-billing .pl-edit-bar small{color:var(--v2-muted)!important;font-size:.78rem}
body.v2-billing .pl-edit-bar .pl-msg{flex:1 1 200px;font-size:.82rem}
body.v2-billing .pl-edit-bar .pl-actions{margin:0 0 0 auto;display:flex;gap:8px}
body.v2-billing .pl-edit-bar .pl-actions .btn:disabled{opacity:.45}

/* ---------- print bill (billing_print.cfm result) ---------- */
body.v2-pg-print .card-body>.card-body{padding:0!important}
body.v2-pg-print .card-body>br{display:none}
body.v2-pg-print .card-body[style*="text-align:center"] h6{font-size:1.1rem!important;font-weight:800;letter-spacing:-.01em}
body.v2-pg-print .card-body[style*="text-align:center"] p{font-size:.84rem!important;color:var(--v2-text-2);line-height:1.6}
body.v2-pg-print .card-body[style*="text-align:center"] p strong{color:var(--v2-text)}
body.v2-pg-print table.border{border:1px solid var(--v2-border)!important;border-radius:var(--v2-radius-xs);border-collapse:separate;border-spacing:0;font-size:.84rem!important;padding:0!important}
body.v2-pg-print table.border td{padding:6px 10px;color:var(--v2-text)}
body.v2-pg-print table.border .btn{margin-left:8px}
body.v2-pg-print table[style*="Arial"]{font-family:var(--v2-font)!important;font-size:.8rem!important;color:var(--v2-text-2);border-color:var(--v2-border)!important;border-radius:var(--v2-radius-xs)}
body.v2-pg-print table[style*="Arial"] td{padding:4px 10px}
body.v2-pg-print #listTable{font-size:.84rem}
body.v2-pg-print table.border,body.v2-pg-print #listTable,body.v2-pg-print table[style*="Arial"]{margin:14px 0 0}

/* ---------- suspense screenshot modal ---------- */
body.v2-pg-suspense .modal-content>div[style]{padding:16px!important}
body.v2-pg-suspense .modal-dialog .row[style]{padding:0!important}
body.v2-pg-suspense .modal-dialog .form-group{margin:0}
body.v2-pg-suspense #modalid{width:auto;max-width:100%;height:auto!important;max-height:75vh;border-radius:var(--v2-radius-sm);border:1px solid var(--v2-border)}

/* ---------- responsive: phones, tablets, laptops, ultra-wide ----------
   theme.css already stacks .form-inline, kills floats, wraps .btn-group and sets the global
   paddings / font sizes below 992px; this block only covers what is specific to the billing markup. */
/* sticky-column widths for the scrolling report tables (rem so they follow the root font size) */
body.v2-billing{--v2-bl-stick1:5.4rem;--v2-bl-stick2:8.5rem}
body.v2-pg-personal-ledger{--v2-bl-stick1:6.6rem}
/* rows that hold a tall multi-select (print bill, personal ledger): top-align so the short
   fields do not sink to the bottom of the list and leave dead space above them */
body.v2-billing #filterForm .row:has(select[multiple]){align-items:flex-start}
body.v2-pg-personal-ledger #filterForm .v2-bl-actions{flex:0 0 100%;max-width:100%;margin-top:8px}
/* DataTables pagination (bootstrap4 ul.pagination) must wrap instead of pushing past the card */
body.v2-billing .dataTables_wrapper .pagination{flex-wrap:wrap;justify-content:center;margin:0}
body.v2-billing .dataTables_wrapper .dataTables_paginate{white-space:normal}
@media (max-width:991px){
  body.v2-billing .content-header{gap:10px 16px;padding-top:16px}
  body.v2-billing .card-primary>.card-header.v2-toolbar,
  body.v2-billing .card-outline>.card-header{padding:10px 14px}
  body.v2-billing #filterForm>div{padding:14px 14px 4px!important}
  body.v2-billing .v2-card-actions,
  body.v2-billing .pl-edit-bar{padding:10px 14px}
  body.v2-billing .v2-bl-actions>*{font-size:.86rem}
  body.v2-billing .v2-bl-actions>.btn,
  body.v2-billing .v2-bl-actions>input,
  body.v2-billing .btn-xs,
  body.v2-billing .table td .btn.btn-sm,
  body.v2-billing .dataTables_wrapper .page-link{min-height:40px;display:inline-flex;align-items:center;justify-content:center}
  body.v2-billing .card-body[style*="overflow"] .table th,
  body.v2-billing .card-body[style*="overflow"] .table td{padding:8px 10px}
  body.v2-billing .card-body[style*="overflow"]{max-height:70vh}
  body.v2-billing .subject-info-arrows input{min-height:40px}
}
@media (max-width:767px){
  /* month picker goes under the title, full width */
  body.v2-billing .content-header{flex-direction:column;align-items:stretch;gap:10px}
  body.v2-billing .v2-page-title{flex:0 0 auto}
  body.v2-billing .content-header .col-md-2{width:100%;max-width:100%}
  body.v2-billing .content-header .input-group{min-width:0;width:100%}
  body.v2-billing .content-header .input-group .form-control{min-height:44px;font-size:16px}
  /* filter forms stack: every column full width, labels above the fields */
  body.v2-billing #filterForm .row>[class*="col-"],
  body.v2-billing #filterForm .row>.form-group{flex:0 0 100%;max-width:100%}
  body.v2-billing #filterForm .form-group{margin-bottom:14px}
  body.v2-billing #filterForm select[multiple]{height:220px}
  body.v2-billing #filterForm .input-group.input-group-sm label{display:block;text-transform:none;letter-spacing:0;font-size:.84rem;font-weight:400;margin:0 0 6px}
  body.v2-billing .subject-info-box-1,
  body.v2-billing .subject-info-box-2{flex-basis:100%;padding:0}
  body.v2-billing .subject-info-box-1 select,
  body.v2-billing .subject-info-box-2 select{height:200px}
  body.v2-billing .subject-info-arrows{gap:10px;padding:0 0 14px!important}
  body.v2-billing .subject-info-arrows input{flex:1 1 auto;max-width:80px}
  /* sticky Unit No + Name columns while the report tables scroll sideways inside their card */
  body.v2-billing .card-body[style*="overflow"] .table th:first-child,
  body.v2-billing .card-body[style*="overflow"] .table td:first-child{position:sticky;left:0;z-index:1;background:var(--v2-surface);box-shadow:inset -1px 0 0 var(--v2-border)}
  body.v2-billing .card-body[style*="overflow"] .table th:first-child:not([colspan]),
  body.v2-billing .card-body[style*="overflow"] .table td:first-child{width:var(--v2-bl-stick1);min-width:var(--v2-bl-stick1);max-width:var(--v2-bl-stick1);overflow:hidden;text-overflow:ellipsis}
  body.v2-billing:not(.v2-pg-personal-ledger) .card-body[style*="overflow"] .table th:not([colspan]):nth-child(2),
  body.v2-billing:not(.v2-pg-personal-ledger) .card-body[style*="overflow"] .table td:nth-child(2){position:sticky;left:var(--v2-bl-stick1);z-index:1;background:var(--v2-surface);max-width:var(--v2-bl-stick2);overflow:hidden;text-overflow:ellipsis;box-shadow:inset -2px 0 0 var(--v2-border-strong)}
  body.v2-billing .card-body[style*="overflow"] .table-striped tbody tr:nth-of-type(odd) td:first-child,
  body.v2-billing .card-body[style*="overflow"] .table-striped tbody tr:nth-of-type(odd) td:nth-child(2),
  body.v2-billing .card-body[style*="overflow"] .table thead th:first-child,
  body.v2-billing .card-body[style*="overflow"] .table thead th:nth-child(2){background:var(--v2-surface-2)}
  body.v2-billing .card-body[style*="overflow"] .table thead tr:first-child th:first-child,
  body.v2-billing .card-body[style*="overflow"] .table thead tr:first-child th:nth-child(2){z-index:3}
  body.v2-billing .card-body[style*="overflow"] .table th[colspan]:first-child{box-shadow:inset -2px 0 0 var(--v2-border-strong)}
  /* monthly receipt statement (DataTable inside .table-responsive): keep the receipt number in view */
  body.v2-pg-month-receipt #listTable th:first-child,
  body.v2-pg-month-receipt #listTable td:first-child{position:sticky;left:0;z-index:1;background:var(--v2-surface);box-shadow:inset -1px 0 0 var(--v2-border)}
  body.v2-pg-month-receipt #listTable thead th:first-child,
  body.v2-pg-month-receipt #listTable tbody tr:nth-of-type(odd) td:first-child{background:var(--v2-surface-2)}
  body.v2-billing .dataTables_wrapper .dataTables_length label,
  body.v2-billing .dataTables_wrapper .dataTables_filter label{width:100%}
  body.v2-billing .dataTables_wrapper .dataTables_length select{flex:1}
}
@media (max-width:575px){
  /* action rows: one full-width tappable button per line */
  body.v2-billing .v2-bl-actions{gap:8px}
  body.v2-billing .v2-bl-actions>*{margin:0;flex:1 1 100%;max-width:100%;white-space:normal}
  body.v2-billing .v2-bl-actions>.v2-push{margin-left:0}
  body.v2-billing .v2-card-actions{padding:10px 12px}
  body.v2-billing .v2-card-actions>*{margin:0}
  body.v2-billing .pl-edit-bar .pl-actions{margin:0;width:100%}
  body.v2-billing .pl-edit-bar .pl-actions .btn{flex:1 1 auto}
  body.v2-billing .v2-page-desc{font-size:.8rem}
  body.v2-billing .card-body[style*="overflow"] .table{font-size:.78rem}
  body.v2-billing .card-body[style*="overflow"] .table th,
  body.v2-billing .card-body[style*="overflow"] .table td{padding:7px 8px}
  body.v2-billing .card-body[style*="overflow"] thead tr+tr th{font-size:.78rem}
  body.v2-pg-print table.border td,
  body.v2-pg-print table[style*="Arial"] td{display:block;width:100%!important;padding:4px 8px}
  body.v2-pg-print table.border .btn{margin:6px 0 0}
}
@media (max-width:400px){
  body.v2-billing{--v2-bl-stick1:5rem;--v2-bl-stick2:7.2rem}
}
@media (min-width:576px) and (max-width:991px){
  /* tablets: buttons stay inline but share the row evenly so no dead space is left on the right */
  body.v2-billing .v2-bl-actions>.btn,
  body.v2-billing .v2-bl-actions>input{flex:1 1 auto;text-align:center}
  body.v2-billing .v2-card-actions>.btn-info{flex:0 0 auto}
}
@media (min-width:768px) and (max-width:1199px){
  /* tablets landscape / small laptops: let the filter columns breathe instead of a 25% col-md-3 */
  body.v2-billing #filterForm .row>.col-md-3{flex:0 0 33.333%;max-width:33.333%}
  body.v2-billing #filterForm .row>.col-md-9{flex:0 0 66.667%;max-width:66.667%}
}
@media (min-width:1800px){
  body.v2-billing .card-body[style*="overflow"]{max-height:80vh}
}
