/* Bill UI is scoped to this module; theme tokens keep its surfaces consistent. */
#page-income.bills-active #incomeSummary,
#page-income.bills-active #incomeSingleYearControls { display:none !important; }
.bill-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:18px; margin:18px 0; }
.bill-heading h2 { font-size:20px; margin:0 0 8px; }
.bill-heading > .btn { flex:none; }
.bill-help { color:var(--text-muted); font-size:12px; line-height:1.75; margin:8px 0 14px; overflow-wrap:anywhere; }
.bill-filters,.bill-bulk-controls,.bill-pager { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:12px 0; }
.bill-filters label,.bill-bulk-controls label { display:flex; align-items:center; gap:7px; font-size:12px; color:var(--text-secondary); }
.bill-filters select,.bill-bulk-controls select,.bill-bulk-controls input,.bill-table select,.bill-table input:not([type=checkbox]) {
  background:var(--bg-input); color:var(--text-primary); border:1px solid var(--border-color); border-radius:var(--radius-sm,8px); padding:7px 9px; font:inherit; min-height:34px; max-width:100%;
}
.bill-table input[type=checkbox],.bill-filters input[type=checkbox] { width:17px; height:17px; accent-color:var(--accent-gold,#d4ae65); cursor:pointer; flex:none; }
.bill-table :focus-visible,.bill-pager :focus-visible,.bill-filters :focus-visible,.bill-dialog :focus-visible { outline:2px solid var(--accent-gold,#d4ae65); outline-offset:2px; }
.bill-summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.bill-metric { padding:16px; margin:0; min-width:0; }
.bill-metric span { display:block; color:var(--text-muted); font-size:12px; }
.bill-metric strong { display:block; font-size:24px; font-variant-numeric:tabular-nums; margin-top:8px; overflow-wrap:anywhere; }
.bill-metric small { color:var(--text-muted); font-size:11px; }
.bill-error { background:var(--bg-card); color:var(--danger,#e37474); border:1px solid currentColor; border-radius:var(--radius-sm,8px); padding:12px 14px; font-size:13px; line-height:1.6; margin:12px 0; overflow-wrap:anywhere; }
.bill-error[hidden] { display:none; }
.bill-table-wrap { overflow:auto; max-width:100%; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; margin-top:12px; }
.bill-table { border-collapse:collapse; width:100%; min-width:1080px; font-size:12px; }
.bill-table th,.bill-table td { padding:12px 10px; text-align:left; border-bottom:1px solid var(--border-color); vertical-align:top; }
.bill-table th { color:var(--text-muted); font-weight:500; background:var(--bg-card); position:sticky; top:0; z-index:1; white-space:nowrap; }
.bill-table td { line-height:1.6; }
.bill-table td:first-child { white-space:nowrap; }
.bill-table .bill-description { min-width:170px; max-width:300px; overflow-wrap:anywhere; }
.bill-description strong,.bill-description small { display:block; }
.bill-description small,.bill-muted { color:var(--text-muted); font-size:11px; }
.bill-table .bill-money { white-space:nowrap; text-align:right; font-variant-numeric:tabular-nums; }
.bill-table .bill-money strong { display:block; }
.bill-kind { display:inline-block; border:1px solid var(--border-color); border-radius:6px; padding:1px 6px; white-space:nowrap; }
.bill-kind-review,.bill-warning { color:var(--accent-gold,#d4ae65); }
.bill-kind-expense { color:var(--text-primary); }
.bill-row-excluded { opacity:.6; }
.bill-row-duplicate td { background:color-mix(in srgb,var(--accent-gold,#d4ae65) 5%,transparent); }
.bill-pager { justify-content:flex-end; color:var(--text-muted); font-size:12px; }
.bill-empty { color:var(--text-muted); padding:32px 18px; text-align:center; font-size:13px; line-height:1.8; }
.bill-batches { margin-top:20px; padding:14px 16px; font-size:13px; }
.bill-batches summary { cursor:pointer; font-weight:600; }
.bill-batch { display:flex; align-items:center; justify-content:space-between; gap:12px; border-top:1px solid var(--border-color); padding:12px 0; margin-top:10px; }
.bill-batch > div { min-width:0; overflow-wrap:anywhere; }
.bill-batch strong,.bill-batch small { display:block; }
.bill-batch small { color:var(--text-muted); margin-top:5px; }
.bill-batch .btn { flex:none; }
#billDialogOverlay { z-index:1150; }
#billDialogOverlay .bill-dialog { width:calc(100vw - 40px); max-width:1380px; height:auto; min-height:0; }
#billDialogOverlay .bill-dialog.bill-classify-dialog { max-width:540px; }
#billDialogOverlay .modal-body { min-height:0; overflow:auto; }
.bill-dialog .modal-header h3 { margin:0; }
.bill-upload-fields { display:grid; grid-template-columns:1.5fr 1fr 1fr; gap:14px; }
.bill-upload-fields .form-group { margin-bottom:4px; min-width:0; }
.bill-upload-fields input[type=file] { min-width:0; width:100%; font-size:12px; padding:8px 0; }
.bill-preview-summary { border-top:1px solid var(--border-color); padding-top:15px; margin-top:20px; }
.bill-preview-meta { display:flex; flex-wrap:wrap; gap:8px 18px; font-size:12px; color:var(--text-secondary); margin:10px 0; line-height:1.7; }
.bill-preview-meta strong { color:var(--text-primary); }
.bill-dialog .bill-table-wrap { max-height:45vh; max-height:45dvh; }
.bill-dialog .bill-table { min-width:1180px; }
.bill-dialog .bill-table select { width:112px; }
.bill-dialog .bill-table input:not([type=checkbox]) { width:120px; }
.bill-dialog .bill-select-cell { min-width:55px; width:55px; }
.bill-dialog .bill-issue-cell { min-width:145px; max-width:240px; overflow-wrap:anywhere; }
.bill-dialog .bill-bulk-controls { padding:10px 12px; background:var(--bg-card); border:1px solid var(--border-color); border-radius:var(--radius-sm,8px); }
.bill-dialog .bill-bulk-controls input { width:125px; }
.bill-dialog .modal-footer { align-items:center; flex-wrap:wrap; }
.bill-dialog .bill-footer-status { margin-right:auto; color:var(--text-muted); font-size:12px; line-height:1.5; }
.bill-dialog .bill-warning-list { padding-left:20px; font-size:12px; line-height:1.7; color:var(--text-muted); }
.bill-dialog .bill-classify-note { width:100%; min-height:76px; resize:vertical; background:var(--bg-input); color:var(--text-primary); border:1px solid var(--border-color); padding:10px; border-radius:var(--radius-sm,8px); font:inherit; }
@media(max-width:767px) {
  .bill-heading { flex-direction:column; gap:4px; }
  .bill-heading > .btn { width:100%; justify-content:center; min-height:44px; }
  .bill-summary { grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:8px; }
  .bill-metric:first-child { grid-column:1/-1; }
  .bill-metric { padding:12px; }
  .bill-metric strong { font-size:22px; }
  #billDialogOverlay .bill-dialog { width:100%; max-height:calc(100dvh - 16px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)); }
  .bill-upload-fields { grid-template-columns:minmax(0,1fr); gap:10px; }
  .bill-filters select,.bill-bulk-controls select,.bill-bulk-controls input,.bill-table select,.bill-table input:not([type=checkbox]),.bill-upload-fields input,.bill-upload-fields select,.bill-classify-dialog input,.bill-classify-dialog select,.bill-classify-note { font-size:16px; }
  .bill-dialog .bill-bulk-controls { align-items:stretch; }
  .bill-dialog .bill-bulk-controls label { flex:1 1 100%; }
  .bill-dialog .bill-bulk-controls select,.bill-dialog .bill-bulk-controls input { flex:1; min-width:0; width:auto; }
  .bill-dialog .bill-table-wrap { max-height:40vh; max-height:40dvh; }
  .bill-dialog .bill-footer-status { flex:1 1 100%; }
  .bill-dialog .modal-footer > .btn { flex:1; }
  .bill-batch { align-items:flex-start; }
  .bill-batch .btn { white-space:normal; max-width:85px; }
}
/* Compact responsive filters and readable tag chips. */
.bill-filters input:not([type=checkbox]) { background:var(--bg-input); color:var(--text-primary); border:1px solid var(--border-color); border-radius:var(--radius-sm,8px); padding:7px 9px; min-height:34px; font:inherit; max-width:100%; min-width:0; }
.bill-filters label { min-width:0; }
.bill-tags { display:flex; flex-wrap:wrap; gap:4px; margin-top:4px; }
.bill-tags span { background:var(--bg-input); color:var(--text-secondary); border:1px solid var(--border-color); border-radius:4px; padding:1px 5px; overflow-wrap:anywhere; }
.bill-table td:last-child .btn { margin-bottom:5px; }
@media(max-width:767px) {
  .bill-filters { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
  .bill-filters label { flex-direction:column; align-items:stretch; }
  .bill-filters label:has(#billSearch),.bill-filters label:has(#billVisibility) { grid-column:1/-1; }
  .bill-filters input:not([type=checkbox]),.bill-filters select { width:100%; min-width:0; font-size:16px; }
  .bill-filters label:has(input[type=checkbox]) { flex-direction:row; align-items:center; }
}
.bill-extra-filters { flex:1 1 100%; order:2; width:100%; border:1px solid var(--border-color); border-radius:var(--radius-sm,8px); padding:9px 12px; }
.bill-extra-filters summary { color:var(--text-secondary); font-size:12px; cursor:pointer; }
.bill-extra-filters > .bill-filters { margin-bottom:0; }
@media(max-width:767px) { .bill-extra-filters { grid-column:1/-1; box-sizing:border-box; } }
/* Ledger analysis uses the same theme, with wider desktop reading space. */
@media(min-width:1100px) { .page-container:has(#page-income.active.bills-active) { max-width:1900px; width:100%; box-sizing:border-box; } }
.bill-heading-actions { display:flex; flex-wrap:wrap; gap:8px; flex-shrink:0; }
.bill-summary { grid-template-columns:repeat(4,minmax(0,1fr)); }
.bill-filters [hidden] { display:none !important; }
.bill-analytics { display:grid; grid-template-columns:minmax(0,1.7fr) minmax(280px,1fr); gap:16px; margin:18px 0; }
.bill-chart-card { min-width:0; padding:18px; margin:0; }
.bill-chart-card h3,.bill-ledger-toolbar h3 { margin:0 0 8px; font-size:16px; }
.bill-chart-canvas { position:relative; height:300px; }
.bill-pie-canvas { position:relative; height:220px; }
.bill-breakdown { padding:0; margin:12px 0; list-style:none; max-height:220px; overflow:auto; }
.bill-breakdown li { display:grid; grid-template-columns:minmax(0,1fr) auto 48px; gap:10px; padding:6px 0; border-bottom:1px solid var(--border-color); font-size:12px; }
.bill-breakdown li span { overflow-wrap:anywhere; }
.bill-breakdown li small { color:var(--text-muted); text-align:right; }
.bill-month-details,.bill-income-details { font-size:12px; margin-top:14px; }
.bill-month-details summary,.bill-income-details summary { cursor:pointer; color:var(--text-secondary); }
.bill-month-details .bill-table-wrap { max-height:300px; }
.bill-month-table { width:100%; min-width:400px; border-collapse:collapse; }
.bill-month-table th,.bill-month-table td { padding:9px; text-align:right; border-bottom:1px solid var(--border-color); font-size:12px; white-space:nowrap; }
.bill-month-table th:first-child,.bill-month-table td:first-child { text-align:left; }
.bill-ledger-toolbar { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:10px; }
body.bill-focus-active { overflow:hidden; }
body.bill-focus-active .page-container,body.bill-focus-active #page-income { animation:none !important; transform:none !important; filter:none !important; backdrop-filter:none !important; contain:none !important; }
#isub-bills.bill-expanded { position:fixed; inset:0; z-index:1040; overflow:auto; background:var(--bg-primary,#090d15); padding:20px 28px; box-sizing:border-box; }
#isub-bills.bill-expanded .bill-heading { position:sticky; top:-20px; z-index:4; background:var(--bg-primary,#090d15); padding:12px 0; margin-top:0; }
@media(max-width:1000px) { .bill-summary { grid-template-columns:repeat(2,minmax(0,1fr)); } .bill-analytics { grid-template-columns:minmax(0,1fr); } }
@media(max-width:767px) {
  .bill-summary .bill-metric:first-child { grid-column:auto; }
  .bill-metric strong { font-size:20px; }
  .bill-heading-actions { width:100%; }
  .bill-heading-actions .btn { flex:1; min-height:44px; }
  .bill-chart-card { padding:12px; }
  .bill-chart-canvas { height:240px; }
  #isub-bills.bill-expanded { padding:12px; }
  #isub-bills.bill-expanded .bill-heading { top:-12px; }
}
/* Category choices always expose the full list; custom text is a separate field. */
.bill-category-control { display:flex; flex-direction:column; gap:8px; min-width:0; flex:1; }
.bill-category-control select,.bill-category-control input { min-width:0; width:100%; }
.bill-category-control [hidden] { display:none !important; }
@media(max-width:767px) {
  .bill-filters label:has(#billListSearch),.bill-filters label:has(#billListVisibility) { grid-column:1/-1; }
}
/* Keep dropdown affordances visible even when the active theme resets native arrows. */
.bill-category-control select,#isub-bills .bill-filters select {
  appearance:none; padding-right:30px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239499a6' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 10px center; background-size:12px 8px;
}
.bill-selection-toolbar { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; padding:12px 14px; border:1px solid var(--border-color); border-radius:var(--radius-sm,8px); background:var(--bg-card); }
.bill-selection-toolbar > span { font-size:12px; color:var(--text-secondary); overflow-wrap:anywhere; }
.bill-selection-actions { display:flex; flex-wrap:wrap; gap:8px; }
#billRecords .bill-selection-cell { position:sticky; left:0; z-index:1; background:var(--bg-card); width:42px; min-width:42px; text-align:center; }
#billRecords th.bill-selection-cell { z-index:2; }
#billRecords .bill-selection-cell input { min-width:20px; min-height:20px; }
#billRecords tr.bill-row-selected td { background:color-mix(in srgb,var(--accent-gold,#d4ae65) 9%,var(--bg-card)); }
.bill-batch-field { padding:12px 0; border-bottom:1px solid var(--border-color); }
.bill-batch-toggle { display:flex; align-items:center; gap:10px; font-size:14px; cursor:pointer; min-height:32px; }
.bill-batch-toggle input { width:20px !important; height:20px; accent-color:var(--accent-gold,#d4ae65); flex:none; }
.bill-batch-value { display:flex; flex-direction:column; gap:8px; margin:10px 0 0 30px; }
.bill-batch-value > label { font-size:12px; color:var(--text-secondary); }
.bill-batch-value [hidden],.bill-batch-value[hidden] { display:none !important; }
.bill-record-note { margin-top:5px; color:var(--text-muted); white-space:pre-wrap; overflow-wrap:anywhere; font-size:11px; }
@media(max-width:767px) {
  .bill-selection-actions { width:100%; }
  .bill-selection-actions .btn { flex:1 1 auto; min-height:40px; }
  .bill-batch-toggle { min-height:44px; }
  .bill-batch-value { margin-left:0; }
}
.bill-batch-value select,.bill-batch-value input:not([type=checkbox]) {
  width:100%; min-width:0; min-height:40px; padding:9px 12px; box-sizing:border-box;
  color:var(--text-primary); background-color:var(--bg-input); border:1px solid var(--border-color); border-radius:var(--radius-sm,8px); font:inherit;
}
.bill-batch-value .bill-category-control select { padding-right:30px; }
@media(max-width:767px) { .bill-batch-value select,.bill-batch-value input:not([type=checkbox]) { font-size:16px; min-height:44px; } }

/* Shared import and manual-entry controls keep the existing theme geometry. */
.bill-import-option { display:flex; align-items:flex-start; gap:10px; line-height:1.6; margin:12px 0; }
.bill-import-option input[type="checkbox"] { flex:0 0 auto; width:18px; height:18px; margin-top:4px; }
.bill-manual-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 16px; }
.bill-manual-fields .form-group { min-width:0; }
.bill-manual-fields input,.bill-manual-fields select { max-width:100%; min-width:0; }
@media (max-width:600px) { .bill-manual-fields { grid-template-columns:1fr; } }
