body[data-page="receivables"] [hidden] { display: none !important; }
#accessStatus { padding: 32px; }
.debt-main { min-width: 0; padding: 28px; }
.debt-tabs { margin-bottom: 18px; }
.debt-card { padding: 18px; }
.debt-section-head { align-items: flex-start; }
.debt-section-actions { min-width: 0; justify-content: flex-end; }
.debt-table-summary { white-space: normal; text-align: right; }
.debt-toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.debt-toolbar label, .debt-form-grid label { display: grid; gap: 7px; font-size: 13px; color: #475569; }
.debt-search { flex: 1; min-width: 220px; }
.debt-search .debt-combobox { width: 100%; }
.debt-main input, .debt-main select, #editDialog input, #editDialog select, #editDialog textarea { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--text); padding: 9px 11px; font: inherit; }
.debt-combobox { position: relative; min-width: 118px; }
.debt-combobox input { padding-right: 38px; }
.debt-combobox-toggle { position: absolute; top: 1px; right: 1px; width: 36px; height: 38px; border: 0; border-radius: 0 9px 9px 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 17px; }
.debt-combobox-toggle:hover { background: #f8fafc; color: var(--text); }
.debt-combobox-menu { position: absolute; top: calc(100% + 5px); left: 0; z-index: 160; display: none; width: max-content; min-width: 100%; max-width: min(360px, calc(100vw - 32px)); max-height: 260px; overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.debt-combobox.open .debt-combobox-menu { display: grid; gap: 3px; }
.debt-combobox-menu button { border: 0; border-radius: 7px; background: transparent; color: var(--text); padding: 9px 10px; text-align: left; white-space: nowrap; cursor: pointer; font: inherit; }
.debt-combobox-menu button:hover, .debt-combobox-menu button:focus, .debt-combobox-menu button[aria-selected="true"] { outline: 0; background: #f1f5f9; }
.debt-combobox-empty { padding: 9px 10px; color: var(--muted); white-space: nowrap; }
.debt-freshness { margin: 14px 0 10px; padding: 10px 12px; border: 1px solid var(--soft-line); border-radius: 8px; background: #f8fafc; color: var(--muted); font-size: 12px; line-height: 1.45; }
.debt-freshness:empty { display: none; }
.debt-table-scroll { overflow: auto; max-height: 65vh; margin-top: 16px; border-top: 1px solid #cbd5e1; }
.debt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.debt-table th { position: sticky; top: 0; background: #fff; color: var(--muted); font-size: 12px; font-weight: 650; text-align: left; white-space: nowrap; z-index: 24; box-shadow: 0 1px 0 #cbd5e1; }
.debt-table th, .debt-table td { padding: 13px 10px; vertical-align: middle; }
.debt-table td { border-bottom: 1px solid #e2e8f0; }
.debt-table td { min-width: 110px; }
.debt-table .select-cell { width: 42px; min-width: 42px; padding: 10px 8px; text-align: center; cursor: pointer; }
.debt-table .select-cell input { width: 18px; min-height: 18px; height: 18px; margin: 0; padding: 0; border-radius: 4px; cursor: pointer; }
.debt-table .debt-name { min-width: 230px; }
.debt-table .debt-number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.debt-table tbody tr:hover { background: #f8fafc; }
.debt-table th:first-child, .debt-table td:first-child { position: sticky; left: 0; background: #fff; z-index: 25; box-shadow: 1px 0 var(--line); }
.debt-table th:last-child, .debt-table td:last-child { position: sticky; right: 0; background: #fff; z-index: 25; box-shadow: -1px 0 var(--line); }
.debt-table th:first-child { background: #fff; z-index: 26; box-shadow: 1px 0 var(--line), 0 1px 0 #cbd5e1; }
.debt-table th:last-child { background: #fff; z-index: 26; box-shadow: -1px 0 var(--line), 0 1px 0 #cbd5e1; }
.debt-table td small { display: block; color: #64748b; margin-top: 5px; }
.debt-table .debt-hospital-row td { background: #f3f4f6; border-top: 1px solid #374151; border-bottom: 1px solid #cbd5e1; box-shadow: none; }
.debt-table .debt-hospital-row td:first-child { position: static; }
.debt-table .debt-hospital-row td:last-child { box-shadow: -1px 0 #cbd5e1; }
.debt-table .debt-hospital-note { min-width: 220px; max-width: 320px; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: normal; }
.debt-invoice-table { table-layout: fixed; width: max(100%, var(--debt-table-width)); }
.debt-invoice-table th, .debt-invoice-table td { box-sizing: border-box; min-width: 0; padding: 14px 16px; line-height: 1.5; overflow-wrap: anywhere; }
.debt-invoice-table th, .debt-invoice-table th.debt-number { white-space: normal; }
.debt-invoice-table .select-cell { padding: 14px 8px; }
.debt-invoice-table .debt-description { white-space: pre-wrap; }
.debt-invoice-table .debt-hospital-note { min-width: 0; max-width: none; }
#invoiceTable .debt-hospital-row .debt-hospital-note { vertical-align: top; background: #f8fafc; border-left: 1px solid #e2e8f0; }
.debt-import-confirm { display: flex; gap: 10px; margin: 22px 0; line-height: 1.5; }
.debt-import-confirm input { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 3px; }
#importStatus { color: #991b1b; }
#importContent ul { max-height: 220px; overflow: auto; }
.debt-actions { display: flex; flex-wrap: wrap; gap: 5px; min-width: 155px; }
.debt-empty-row:hover { background: transparent !important; }
.debt-table .debt-empty-row .empty-cell { position: static; min-width: 0; height: 120px; padding: 28px 18px; background: #fafafa; color: var(--muted); box-shadow: none; text-align: center; }
.debt-empty-row strong, .debt-empty-row span { display: block; }
.debt-empty-row strong { margin-bottom: 6px; color: #374151; font-size: 14px; }
.debt-empty-row span { font-size: 12px; }
.debt-table-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 49px; padding-top: 16px; }
.debt-table-hint { color: var(--muted); font-size: 12px; }
.debt-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-left: auto; }
.debt-muted { color: #64748b; font-size: 13px; }
#pageStatus:empty, #formStatus:empty, #debtHistoryPageStatus:empty { display: none; }
#pageStatus, #formStatus, #debtHistoryPageStatus { padding: 10px; border-radius: 6px; background: #f0fdfa; color: #115e59; }
#pageStatus.error, #formStatus.error, #debtHistoryPageStatus.error { color: #991b1b; background: #fef2f2; }
body[data-page="receivables"] dialog { box-sizing: border-box; border: 0; border-radius: 12px; padding: 24px; width: min(1400px, calc(100vw - 48px)); max-width: none; max-height: calc(100dvh - 48px); overflow: auto; color: #0f172a; box-shadow: 0 20px 80px #0f172a40; }
body[data-page="receivables"] #historyDialog { width: min(2400px, 94vw); }
body[data-page="receivables"] #historyContent { min-width: 0; }
body[data-page="receivables"] dialog::backdrop { background: #0f172a80; }
.debt-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.debt-dialog-head h2 { margin: 0; }
.debt-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.debt-form-grid .wide { grid-column: 1 / -1; }
.debt-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.debt-balance { background: #f0fdfa; color: #115e59; padding: 14px; font-weight: 600; }
@media (max-width: 760px) { .debt-main { padding: 16px; } .debt-form-grid { grid-template-columns: 1fr; } .debt-toolbar > label { flex: 1 1 180px; } .debt-card { padding: 12px; } .debt-section-head, .debt-table-footer { align-items: stretch; flex-direction: column; } .debt-section-actions, .debt-pagination { justify-content: flex-start; margin-left: 0; } .debt-table-summary { text-align: left; } .debt-table th:first-child, .debt-table td:first-child { position: static; } }
@media (max-width: 760px) { body[data-page="receivables"] dialog, body[data-page="receivables"] #historyDialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); padding: 16px; } }
#historyContent > dl { display: grid; grid-template-columns: 190px 1fr; gap: 10px; }
#historyContent > dl dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.debt-history-version { width: min(640px, 100%); }
.debt-history-list { min-width: 1100px; }
.debt-history-list td { overflow-wrap: anywhere; max-width: 320px; }
.debt-history-table td:last-child { position: static; box-shadow: none; }
.debt-history-table th:last-child { right: auto; z-index: 24; box-shadow: 0 1px 0 #cbd5e1; }
#debtHistoryStatus { color: var(--muted); padding: 10px 0; }
#debtHistoryStatus:empty { display: none; }
