.header-nav .active { color: #083e69; background: #fff; }
.debts-page.locked .topbar, .debts-page.locked .debts-shell { visibility: hidden; }
.debts-shell { max-width: 1320px; }
.debt-summary { margin-bottom: 20px; }
.debt-heading { align-items: center; }
.debt-heading small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.debt-tools { display: flex; gap: 10px; align-items: center; }
.debt-tools input { width: min(390px, 42vw); }
.debt-global-message { min-height: 18px; margin: -8px 0 12px; color: var(--green); font-size: 12px; font-weight: 700; }
.debt-global-message.error { color: var(--red); }
.debt-list { display: grid; gap: 14px; }
.debt-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.debt-card > header { display: grid; grid-template-columns: minmax(240px, 1fr) auto auto; align-items: center; gap: 18px; padding: 17px 18px; background: #f8fafc; }
.debt-customer strong, .debt-customer small { display: block; }
.debt-customer strong { color: var(--blue-dark); font-size: 15px; }
.debt-customer small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.debt-kind { display: inline-flex; margin-left: 7px; padding: 3px 6px; color: #fff; background: var(--blue); border-radius: 5px; font-size: 8px; vertical-align: 2px; }
.debt-card-total { text-align: right; }
.debt-card-total span, .debt-card-total strong { display: block; }
.debt-card-total span { color: var(--muted); font-size: 10px; }
.debt-card-total strong { margin-top: 4px; color: var(--red); font-size: 18px; }
.debt-toggle { min-height: 38px; padding: 0 12px; color: var(--blue-dark); background: var(--blue-soft); border: 1px solid #c7d9e7; border-radius: 8px; font-weight: 750; }
.debt-detail { padding: 16px 18px 18px; border-top: 1px solid var(--line); }
.debt-select-all { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 12px; color: var(--muted); font-size: 11px; font-weight: 700; }
.debt-select-all input, .debt-row input { width: 16px; min-height: 16px; }
.debt-table { width: 100%; border-collapse: collapse; }
.debt-table th, .debt-table td { padding: 10px 9px; border-bottom: 1px solid #edf1f4; text-align: left; font-size: 11px; vertical-align: top; }
.debt-table th { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.debt-date-sort { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 3px 7px; color: #31506a; background: #edf5fa; border: 1px solid #cfdee8; border-radius: 7px; font: inherit; font-weight: 850; text-transform: uppercase; cursor: pointer; }
.debt-date-sort span { color: var(--blue); font-size: 14px; line-height: 1; }
.debt-date-sort:hover, .debt-date-sort:focus-visible { color: #fff; background: var(--blue); border-color: var(--blue); outline: none; }
.debt-date-sort:hover span, .debt-date-sort:focus-visible span { color: #fff; }
.debt-table td:last-child, .debt-table th:last-child { text-align: right; }
.debt-source { display: inline-flex; padding: 4px 7px; border: 0; border-radius: 5px; color: #31506a; background: #eaf4fc; font-size: 8px; font-weight: 800; }
.debt-source-link { text-decoration: none; cursor: pointer; }
.debt-source-link:hover, .debt-source-link:focus-visible { color: #fff; background: var(--blue); outline: none; }
.debt-lines strong, .debt-lines small { display: block; }
.debt-lines small { margin-top: 3px; color: var(--muted); }
.debt-doc { display: inline-block; margin-top: 4px; color: #6f2aa8; font-size: 9px; font-weight: 750; }
.debt-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 15px; }
.debt-actions button { min-height: 38px; padding: 0 12px; border-radius: 8px; font-size: 10px; font-weight: 800; }
.debt-actions .paid-action { color: #fff; background: #0b7a53; border: 1px solid #085f41; }
.debt-actions .paid-action:hover, .debt-actions .paid-action:focus-visible { background: #085f41; outline: none; }
.debt-actions .rs-action { color: #fff; background: #6f2aa8; border: 1px solid #592087; }
.debt-actions .waybill-action { color: #fff; background: var(--green); border: 1px solid #0e6749; }
.debt-selection-total { margin-left: auto; color: var(--muted); font-size: 11px; }
.debt-selection-total strong { color: var(--ink); font-size: 14px; }
.source-editor-dialog { width: min(1180px, calc(100vw - 28px)); height: min(900px, calc(100vh - 28px)); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 18px; overflow: hidden; background: #eef3f7; box-shadow: 0 28px 90px rgba(13,31,45,.38); }
.source-editor-dialog::backdrop { background: rgba(13,31,45,.58); backdrop-filter: blur(3px); }
.source-editor-card { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.source-editor-card > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.source-editor-card > header p, .source-editor-card > header h2 { margin: 0; }
.source-editor-card > header h2 { margin-top: 3px; font-size: 18px; }
.source-editor-card > header small { display: block; margin-top: 3px; color: var(--muted); }
.source-editor-card iframe { width: 100%; height: 100%; border: 0; background: #eef3f7; }
@media (max-width: 760px) {
  .debt-card > header { grid-template-columns: 1fr auto; }
  .debt-card-total { text-align: left; }
  .debt-toggle { grid-column: 2; grid-row: 1 / span 2; }
  .debt-tools { width: 100%; }
  .debt-tools input { width: 100%; }
  .debt-heading { align-items: stretch; flex-direction: column; }
  .debt-table thead { display: none; }
  .debt-table tr { display: grid; grid-template-columns: 26px 1fr auto; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .debt-table td { border: 0; }
  .debt-table td:nth-child(2), .debt-table td:nth-child(3) { grid-column: 2; }
  .debt-table td:last-child { grid-column: 3; grid-row: 1 / span 3; }
  .debt-selection-total { width: 100%; margin-left: 0; }
  .source-editor-dialog { width: calc(100vw - 8px); height: calc(100vh - 8px); border-radius: 12px; }
  .source-editor-card > header { padding: 10px 12px; }
  .source-editor-card > header small { display: none; }
}

.debt-card.debt-yellow { border-color: #e5b620; }
.debt-card.debt-yellow > header { background: #fff5cc; }
.debt-card.debt-yellow .debt-card-total strong { color: #806000; }
.debt-card.debt-orange { border-color: #f08a24; }
.debt-card.debt-orange > header { background: #ffead5; }
.debt-card.debt-orange .debt-card-total strong { color: #a34800; }
.debt-card.debt-red { border-color: #df5252; }
.debt-card.debt-red > header { background: #ffe3e3; }
.debt-card.debt-red .debt-card-total strong { color: #b42323; }
.debt-level { display: block; margin-top: 5px; font-size: 10px; font-weight: 700; }

.account-history h3 { margin: 0 0 7px; color: var(--blue-dark); font-size: 18px; }
.ledger-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ledger-export { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid #14734e; border-radius: 8px; background: #14734e; color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.ledger-export:hover { background: #0d5c3d; }
.ledger-export:focus-visible { outline: 3px solid #80bbf1; outline-offset: 3px; }
.ledger-export:disabled { opacity: .65; cursor: wait; }
.ledger-export svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ledger-export-status { margin: 0 0 12px; color: #08784e; font-size: 12px; }
.ledger-export-status:empty { display: none; }
.ledger-export-status.error { color: #b42323; }
.ledger-intro, .ledger-footnote { color: var(--muted); font-size: 12px; line-height: 1.6; }
.ledger-intro { margin: 0 0 14px; }
.ledger-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
.ledger-table { width: 100%; min-width: 850px; border-collapse: collapse; font-size: 12px; }
.ledger-table th, .ledger-table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid #e5ebf0; vertical-align: top; }
.ledger-table thead { background: #edf3f8; color: #31506a; }
.ledger-table th:nth-child(n+4), .ledger-table td:nth-child(n+4), .ledger-table tfoot td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger-table td:first-child { white-space: nowrap; }
.ledger-table .ledger-description { min-width: 220px; max-width: 430px; overflow-wrap: anywhere; line-height: 1.55; }
.ledger-description small, .ledger-description a { display: block; margin-top: 5px; font-size: 11px; }
.ledger-description small { color: #8a5600; }
.ledger-description a { color: var(--blue); text-decoration: underline; }
.ledger-credit { background: #f1faf6; }
.ledger-credit td:nth-child(5) { color: #08784e; font-weight: 700; }
.ledger-opening, .ledger-table tfoot { background: #f6f8fa; }
.ledger-source { display: inline-block; padding: 4px 6px; border-radius: 4px; font-size: 10px; line-height: 1.5; color: #694b16; background: #fff2d4; min-width: 86px; }
.ledger-source-current { color: #165a8a; background: #e7f2fd; }
.ledger-source-bank, .ledger-source-bank-correction { color: #08784e; background: #d9f0e4; }
.current-debt-actions { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.current-debt-actions > summary { cursor: pointer; color: var(--blue-dark); font-weight: 700; margin-bottom: 14px; }
@media(max-width:760px) { .debt-detail { padding: 12px; } .ledger-table { font-size: 11px; } }

.account-filter { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:8px 0 22px; font-size:12px; }
.account-filter select { width:auto; min-width:200px; }
.account-filter span { color:var(--muted); }
.account-settled strong { color:#08784e; }
.ledger-period { display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; margin:4px 0 16px; padding:14px; border-radius:10px; background:#f4f7fa; }
.ledger-period label { display:grid; gap:6px; color:#31506a; font-size:12px; }
.ledger-period input { width:180px; }
.ledger-period button { min-height:42px; }
.ledger-period-label { font-size:12px; font-weight:700; color:#31506a; }
.ledger-summary { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin:0 0 16px; }
.ledger-summary>div { background:#edf3f8; border-radius:8px; padding:14px; }
.ledger-summary span,.ledger-summary strong { display:block; }
.ledger-summary span { color:var(--muted); font-size:11px; margin-bottom:8px; }
.ledger-summary strong { color:var(--blue-dark); font-size:18px; font-variant-numeric:tabular-nums; }
.ledger-summary>div:nth-child(3) { background:#eaf7f0; }
.ledger-summary>div:nth-child(3) strong { color:#08784e; }
.ledger-summary>div:last-child { border:1px solid #bdd1e1; }
.ledger-description .debt-source { margin-top:7px; font-size:11px; }
@media(max-width:760px) {
  .ledger-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .ledger-summary>div { padding:11px; }
  .ledger-summary strong { font-size:16px; }
  .ledger-period { gap:10px; padding:10px; }
  .ledger-period label { flex:1 1 140px; min-width:0; }
  .ledger-period input { width:100%; min-width:0; }
  .ledger-period button { flex:1 1 130px; }
}

.ledger-admin,.ledger-dialog-actions,.ledger-deleted-row{display:flex;align-items:center;gap:12px;justify-content:space-between;flex-wrap:wrap}
.ledger-admin{margin:12px 0;padding:12px;background:#edf5fb;border-radius:10px}
.ledger-remove{display:block;margin-top:6px;border:1px solid #e6c4c4;border-radius:6px;padding:4px 8px;background:white;color:#a62b2b;cursor:pointer}
.ledger-deleted{margin-top:16px;padding:12px;border:1px solid #d7e2ed;border-radius:10px}
.ledger-deleted summary{cursor:pointer;font-weight:600}.ledger-deleted-row{padding:10px 0;border-bottom:1px solid #e4ebf2}.ledger-deleted-row small{display:block;color:#63758a;margin-top:4px}
#ledger-action-dialog{border:0;border-radius:16px;padding:24px;max-width:560px;width:calc(100% - 32px);max-height:90vh;overflow:auto;color:#153650;box-shadow:0 20px 70px #152f5966}
#ledger-action-dialog::backdrop{background:#10223988}#ledger-action-dialog h2{margin-top:0}#ledger-payment-fields{display:grid;gap:12px}#ledger-payment-fields[hidden]{display:none}
#ledger-payment-fields label{display:grid;gap:6px}#ledger-payment-fields input,#ledger-payment-fields select{width:100%;padding:10px;border:1px solid #c9d7e5;border-radius:8px;font:inherit}#ledger-payment-fields p{font-size:13px;line-height:1.6;color:#596c80}.ledger-dialog-actions{margin-top:16px;justify-content:flex-end}

@media screen and (max-width:760px){
  .ledger-table{min-width:0}.ledger-table .ledger-description{min-width:0;max-width:none}
  .ledger-table td{grid-template-columns:100px minmax(0,1fr);overflow-wrap:anywhere}
  .ledger-table td::before{text-align:left}.ledger-table td>small,.ledger-table td>a,.ledger-table td>div,.ledger-table td>.ledger-remove{grid-column:2}
  .ledger-table .ledger-remove{justify-self:end}.ledger-table tfoot,.ledger-table tfoot tr{display:block}
}

#operation-action-dialog{border:0;border-radius:16px;padding:24px;max-width:600px;width:calc(100% - 32px);max-height:90vh;overflow:auto;color:#153650}#operation-action-dialog::backdrop{background:#10223988}#operation-action-dialog li{padding:6px 0}#operation-action-explanation{line-height:1.7;color:#596c80}
#invoice-presentation-dialog{border:0;border-radius:16px;padding:24px;width:calc(100% - 32px);max-width:640px;max-height:90vh;overflow:auto;color:#153650}#invoice-presentation-dialog::backdrop{background:#10223988}#invoice-presentation-dialog h2{margin-top:0}#invoice-presentation-dialog p{line-height:1.65}.invoice-presentation-field{display:grid;gap:8px;margin:16px 0}.invoice-presentation-field[hidden],#invoice-existing-warning[hidden]{display:none}.invoice-presentation-field input,.invoice-presentation-field select{box-sizing:border-box;width:100%;min-width:0;padding:12px;border:1px solid #c9d7e5;border-radius:8px;font:inherit;background:white;color:inherit}#invoice-presentation-preview{padding:16px;background:#edf7fc;border-radius:10px;font-weight:700;overflow-wrap:anywhere}.invoice-presentation-help{font-size:13px;color:#596c80}#invoice-presentation-sources{padding-left:22px;line-height:1.8}#invoice-existing-warning{margin-top:16px;padding:12px;border:1px solid #e7bb6a;background:#fff9ea;border-radius:10px;font-size:13px}#invoice-existing-warning label{display:flex;gap:8px;align-items:flex-start}#invoice-presentation-dialog .ledger-dialog-actions{flex-wrap:wrap}

.service-group{margin-top:18px;padding:16px;border:1px solid #c8dfec;border-radius:12px;background:#f6fbff}.service-group summary{font-weight:700;cursor:pointer}.service-group p,.service-group li{line-height:1.7}.service-group li{padding:6px 0}.service-group small{display:block;color:#64788a}#service-group-dialog{border:0;border-radius:16px;padding:24px;width:calc(100% - 32px);max-width:650px;max-height:90vh;overflow:auto;color:#153650}#service-group-dialog::backdrop{background:#10223988}#service-group-dialog h2{margin-top:0}#service-group-dialog li,#service-group-summary{line-height:1.8}#service-group-target-field[hidden]{display:none}#service-group-dialog .ledger-dialog-actions{flex-wrap:wrap}
