:root {
  color-scheme: light;
  --ink: #17253b;
  --muted: #64748b;
  --line: #dce4ee;
  --surface: #ffffff;
  --canvas: #f3f6fb;
  --blue: #2258a5;
  --blue-dark: #173e78;
  --danger: #b42332;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 280px; min-height: 100vh; color: var(--ink); background: var(--canvas); font-size: .875rem; line-height: 1.5; }
[hidden], .d-none { display: none !important; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
h1, h2, h3, h4, h5, h6, p { margin-top: 0; }
h1, .display-6 { font-size: clamp(1.65rem, 2.5vw, 2.1rem); line-height: 1.2; }
h2, .h2 { font-size: 1.4rem; }
h3, .h3 { font-size: 1.2rem; }
h4, .h4 { font-size: 1.1rem; }
.h5 { font-size: 1rem; }
.h6 { font-size: .95rem; }
h1, h2, h3, h4, .h2, .h3, .h4, .h5, .h6 { font-weight: 650; }
small, .small, .form-text { font-size: .85rem; }
strong, .fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.lead { font-size: 1rem; }
.text-uppercase { text-transform: uppercase; letter-spacing: .08em; }
.text-primary { color: var(--blue); }
.text-body-secondary, .form-text { color: var(--muted); }
.text-break { overflow-wrap: anywhere; }
.text-end { text-align: right; }
.d-flex { display: flex; }
.d-inline-block { display: inline-block; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.align-items-end { align-items: end; }
.align-items-start { align-items: start; }
.ms-auto { margin-left: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.w-100 { width: 100%; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: 1rem; }
.vstack { display: flex; flex-direction: column; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2.25rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.p-2 { padding: .5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.pt-3 { padding-top: 1rem; }
.py-4 { padding-block: 1.5rem; }
.py-5 { padding-block: 3rem; }
.bg-white { background: white; }
.border { border: 1px solid var(--line); }
.border-0 { border: 0; }
.border-top { border-top: 1px solid var(--line); }
.rounded-3 { border-radius: .75rem; }
.rounded-4 { border-radius: 1rem; }
.shadow-sm { box-shadow: 0 5px 22px rgba(22, 42, 74, .06); }
.position-absolute { position: absolute; }
.top-0 { top: 0; }
.start-0 { left: 0; }
.visually-hidden-focusable:not(:focus) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.visually-hidden-focusable:focus { z-index: 100; }

.app-main { min-width: 0; margin-left: 15.5rem; }
.page-loading { display: flex; align-items: center; justify-content: center; gap: .7rem; min-height: 50vh; color: var(--muted); }
.loading-spinner { width: 1.3rem; height: 1.3rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: button-spin .7s linear infinite; }
.container { width: min(100%, 82rem); margin-inline: auto; padding-inline: clamp(1rem, 3vw, 2.5rem); }
.statement-main { max-width: 58rem; }
.statement-main #statement-title,
.statement-main .statement-name,
.statement-main #statement-client,
.statement-main #statement-instructions,
.statement-main #statement-selected-bill,
.statement-main #statement-bills td:first-child,
#payment-rows td:first-child { overflow-wrap: anywhere; }
.statement-main #statement-bills td:first-child,
#payment-rows td:first-child { max-width: 14rem; }
.statement-main .form-select { min-width: 0; }
.payment-account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .75rem; }
.payment-account { min-width: 0; padding: .85rem; border: 1px solid var(--line); border-radius: .7rem; background: #f9fbfe; overflow-wrap: anywhere; }
.sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; width: 15.5rem; display: flex; flex-direction: column; padding: 1.35rem .9rem; color: #e8eef8; background: #152942; box-shadow: 4px 0 24px rgba(7, 20, 38, .12); }
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: .4rem .6rem 2rem; font-weight: 700; font-size: 1rem; }
.brand-mark { display: inline-grid; place-items: center; flex: 0 0 2rem; width: 2rem; height: 2rem; border-radius: .65rem; color: #122740; background: #a8d5ff; font-weight: 800; }
.sidebar-caption { margin: .4rem .9rem .7rem; color: #91a9c6; font-size: .68rem; font-weight: 700; letter-spacing: .16em; }
.sidebar-nav { display: grid; gap: .25rem; }
.sidebar .nav-link { display: flex; align-items: center; gap: .75rem; padding: .72rem .85rem; border-radius: .65rem; color: #c7d7e9; text-decoration: none; font-size: .93rem; }
.sidebar .nav-link span { width: 1.3rem; text-align: center; font-size: 1.13rem; }
.sidebar .nav-link:hover, .sidebar .nav-link:focus-visible { color: #fff; background: #24415f; }
.sidebar .nav-link.active { color: #fff; background: #2c5682; font-weight: 650; }
.sidebar-footer { margin-top: auto; padding: 1.1rem .6rem .3rem; border-top: 1px solid #38506b; }
.sidebar-user { display: grid; gap: .1rem; margin-bottom: .8rem; }
.sidebar-user span { color: #a7bdd5; font-size: .83rem; }
.sidebar-close, .mobile-header, .sidebar-overlay { display: none; }
.btn-sidebar { width: 100%; border-color: #617a98 !important; color: #e8eef8 !important; background: transparent !important; }
.btn-sidebar:hover { background: #2c4d71 !important; }

.card { min-width: 0; background: var(--surface); border-radius: .9rem; }
.form-dialog { width: min(42rem, calc(100% - 2rem)); max-width: none; max-height: calc(100dvh - 2rem); padding: 0; border: 0; border-radius: .9rem; color: var(--ink); background: var(--surface); overflow-y: auto; box-shadow: 0 20px 65px rgba(9, 24, 42, .28); }
.invoice-detail-dialog { width: min(58rem, calc(100% - 2rem)); }
.invoice-detail-dialog .section-heading { padding-right: 2.75rem; }
.invoice-detail-dialog #invoice-detail-title { overflow-wrap: anywhere; }
.invoice-detail-dialog #invoice-detail-items td:first-child { overflow-wrap: anywhere; max-width: 18rem; }
.form-dialog::backdrop { background: rgba(9, 24, 42, .62); }
.form-dialog .card { box-shadow: none; }
.form-dialog .dialog-message { margin: 1rem 1rem 0; }
.dialog-close { position: absolute; z-index: 1; top: .55rem; right: .65rem; display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; border: 0; border-radius: .5rem; color: var(--ink); background: transparent; font-size: 1.6rem; cursor: pointer; }
.dialog-close:hover, .dialog-close:focus-visible { background: #edf5ff; outline: 2px solid #8fbbeb; }
.form-dialog h3 { padding-right: 2.75rem; }
.card-body { min-width: 0; }
.section-heading { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; }
.badge { display: inline-flex; align-items: center; padding: .35rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 650; white-space: nowrap; }
.text-bg-light { background: #f7f9fc; }
.alert { padding: .85rem 1rem; border: 1px solid transparent; border-radius: .7rem; margin-bottom: 1.2rem; }
.alert-danger { color: #842028; background: #fff0f1; border-color: #f5c8cc; }
.alert-success { color: #126145; background: #eaf8f0; border-color: #b9e9ca; }
.alert-info { color: #185079; background: #edf6fc; border-color: #c7e0f2; }

.row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.row > * { grid-column: span 12; min-width: 0; }
.row.g-2 { gap: .65rem; }
.row.gy-4 { gap: 1.5rem; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }
dl.row { gap: .55rem 0; }
dl.row dt, dl.row dd { margin: 0; }
dl.row dt { font-weight: 600; }
.table-responsive { width: 100%; overflow-x: auto; }
.table-controls { display: flex; flex-wrap: wrap; align-items: end; gap: .7rem; margin-bottom: .85rem; }
.table-controls label { display: grid; gap: .25rem; font-size: .82rem; font-weight: 650; }
.table-control-search { flex: 1 1 14rem; }
.table-control-status { flex: 1 1 9rem; }
.table-control-date { flex: 1 1 9rem; }
.table-control-size { flex: 0 1 9rem; }
.table-pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .7rem; margin-top: .85rem; color: var(--muted); font-size: .86rem; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .7rem; margin-bottom: 1.3rem; }
.metric-card { display: grid; align-content: start; gap: .25rem; min-height: 7rem; padding: .9rem; border: 1px solid var(--line); border-radius: .7rem; background: #f9fbfe; }
.metric-label { color: var(--muted); font-size: .83rem; font-weight: 650; }
.metric-value { font-size: clamp(1.1rem, 1.8vw, 1.35rem); overflow-wrap: anywhere; }
.business-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 1.3rem; }
.business-chart { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .7rem; }
.chart-list { display: grid; gap: .65rem; }
.chart-item { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: .35rem .7rem; align-items: center; }
.chart-label { font-size: .82rem; font-weight: 650; }
.chart-tracks { display: grid; gap: .2rem; }
.chart-track { min-width: 0; height: .65rem; border-radius: 99px; background: #edf2f8; overflow: hidden; }
.chart-bar { display: block; height: 100%; min-width: 0; border-radius: 99px; }
.chart-billed { background: #2258a5; }
.chart-received { background: #21a09a; }
.chart-aging { background: #d17b38; }
.chart-value { grid-column: 2; min-width: 0; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.chart-legend { display: flex; gap: 1rem; margin-bottom: .8rem; font-size: .78rem; }
.chart-legend span::before { content: ''; display: inline-block; width: .7rem; height: .7rem; margin-right: .35rem; border-radius: .15rem; }
.legend-billed::before { background: #2258a5; }
.legend-received::before { background: #21a09a; }
.legend-approved::before { background: #198754; }
.legend-due::before { background: #2258a5; }
.client-chart-list { display: grid; gap: .9rem; }
.client-chart-item { display: grid; gap: .25rem; min-width: 0; }
.client-chart-label { font-size: .82rem; overflow-wrap: anywhere; }
.client-invoice-track { display: flex; height: .8rem; overflow: hidden; border-radius: 99px; background: #edf2f8; }
.client-chart-approved { background: #198754; }
.client-chart-due { background: #2258a5; }
.client-payment-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem; }
.client-payment-ring { display: grid; place-items: center; width: 8.5rem; height: 8.5rem; flex: 0 0 8.5rem; border-radius: 50%; background: #e7edf4; }
.client-payment-ring-total { display: grid; place-items: center; width: 5.6rem; height: 5.6rem; border-radius: 50%; background: white; font-size: 1.35rem; }
.client-payment-labels { display: grid; gap: .5rem; }
.client-payment-label::before { content: ''; display: inline-block; width: .7rem; height: .7rem; margin-right: .45rem; border-radius: .15rem; }
.client-payment-approved::before { background: #198754; }
.client-payment-pending::before { background: #d19b25; }
.client-payment-rejected::before { background: #b42332; }
.table { width: 100%; min-width: 650px; border-collapse: collapse; text-align: left; }
.table th, .table td { padding: .7rem .65rem; border-bottom: 1px solid #e8edf4; vertical-align: middle; }
.table th { color: #40536e; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td:first-child { font-weight: 600; }
.table td:last-child { min-width: 6rem; }
#invoice-rows td:first-child, #invoice-rows td:nth-child(3) { white-space: nowrap; }
.invoice-item { background: #fafbfd; }
.invoice-item .form-label { width: 100%; }

.form-label { display: block; margin-bottom: .4rem; font-size: .88rem; font-weight: 600; }
.form-control, .form-select { display: block; width: 100%; min-height: 2.65rem; padding: .57rem .75rem; border: 1px solid #c9d5e4; border-radius: .56rem; color: var(--ink); background: #fff; }
textarea.form-control { resize: vertical; min-height: 6rem; }
.form-control:focus, .form-select:focus { outline: 2px solid #8fbbeb; outline-offset: 1px; border-color: #5e94d5; }
.form-control:disabled, .form-select:disabled { color: #41536d; background: #f3f5f8; opacity: 1; }
.form-check { display: flex; align-items: center; gap: .55rem; }
.form-check-input { width: 1.1rem; height: 1.1rem; margin: 0; }
.form-check-label { margin: 0; }
.input-group { display: flex; }
.input-group .form-control { min-width: 0; border-radius: .56rem 0 0 .56rem; }
.input-group .btn { border-radius: 0 .56rem .56rem 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 2.55rem; padding: .55rem .9rem; border: 1px solid transparent; border-radius: .56rem; font-weight: 600; text-decoration: none; line-height: 1.2; }
.btn[aria-busy="true"]::before { content: ''; width: .9em; height: .9em; margin-right: .55em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: button-spin .7s linear infinite; }
@keyframes button-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn[aria-busy="true"]::before, .loading-spinner { animation-duration: 1.8s; } }
.btn:focus-visible, .menu-button:focus-visible, .sidebar-close:focus-visible { outline: 3px solid #88b8ee; outline-offset: 2px; }
.btn-primary { color: #fff; background: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline-primary { color: var(--blue); border-color: #9abce5; background: #fff; }
.btn-outline-primary:hover { background: #edf5ff; }
.btn-outline-secondary { color: #40536d; border-color: #b7c5d6; background: #fff; }
.btn-outline-secondary:hover { background: #f1f5fa; }
.btn-outline-danger { color: var(--danger); border-color: #e8aab2; background: #fff; }
.btn-outline-danger:hover { background: #fff0f2; }
.btn-sm { min-height: 2rem; padding: .3rem .55rem; font-size: .82rem; }
.img-fluid { max-width: 100%; height: auto; }
.invoice-qr { display: block; max-width: 15rem; max-height: 15rem; object-fit: contain; background: #fff; }
.auth-page { display: flex; align-items: center; min-height: 100svh; }
.auth-card { width: 100%; max-width: 31rem; }
.auth-page .container { width: 100%; }
.auth-page .card-body { padding: clamp(1.5rem, 5vw, 2.5rem); }

@media (min-width: 576px) {
  .col-sm-6 { grid-column: span 6; }
}
@media (min-width: 768px) {
  body { font-size: .9375rem; }
  .col-md-2 { grid-column: span 2; }
  .col-md-3 { grid-column: span 3; }
  .col-md-4 { grid-column: span 4; }
  .col-md-5 { grid-column: span 5; }
  .col-md-6 { grid-column: span 6; }
  .col-md-8 { grid-column: span 8; }
  .p-md-4 { padding: 1.5rem; }
  .p-md-5 { padding: 2rem; }
  .py-md-5 { padding-block: 3rem; }
  .mb-md-5 { margin-bottom: 2.25rem; }
}
@media (min-width: 1100px) {
  .col-lg-3 { grid-column: span 3; }
  .col-lg-4 { grid-column: span 4; }
  .col-lg-8 { grid-column: span 8; }
  .col-lg-12 { grid-column: span 12; }
}
@media (max-width: 800px) {
  .btn, .btn-sm, .form-control, .form-select, .menu-button, .sidebar-close { min-height: 2.75rem; }
  .form-control, .form-select { font-size: 1rem; }
  .menu-button, .sidebar-close { min-width: 2.75rem; }
  .app-main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close { display: inline-flex; margin-left: auto; padding: .15rem .45rem; border: 0; border-radius: .4rem; color: #fff; background: transparent; font-size: 1.6rem; }
  .sidebar-overlay:not([hidden]) { position: fixed; z-index: 40; inset: 0; display: block; background: rgba(9, 24, 42, .5); }
  .mobile-header { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; gap: .8rem; min-height: 4rem; padding-inline: 1rem; background: #fff; border-bottom: 1px solid var(--line); }
  .menu-button { width: 2.4rem; height: 2.4rem; border: 1px solid var(--line); border-radius: .5rem; color: var(--ink); background: #fff; font-size: 1.2rem; }
}
@media (max-width: 575px) {
  .section-heading { align-items: center; }
  .section-heading h2 { font-size: 1.15rem; }
  .table { min-width: 580px; }
}
@media (max-width: 767px) {
  .mobile-collapse-table { display: block; min-width: 0; width: 100%; }
  .mobile-collapse-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .mobile-collapse-table tbody { display: grid; gap: .75rem; }
  .mobile-collapse-table tbody tr { display: block; min-width: 0; padding: .4rem .8rem; border: 1px solid var(--line); border-radius: .7rem; background: #fff; }
  .mobile-collapse-table tbody td { display: none; min-width: 0; max-width: none !important; padding: .35rem 0; border: 0; white-space: normal !important; overflow-wrap: anywhere; }
  .mobile-collapse-table tbody td.mobile-row-summary,
  .mobile-collapse-table tbody tr.mobile-row-open td { display: block; }
  .mobile-collapse-table tbody td::before { display: block; content: attr(data-label); color: var(--muted); font-size: .75rem; font-weight: 600; }
  .mobile-collapse-table tbody tr.mobile-row-open td:not(.mobile-row-summary) { border-top: 1px solid #edf1f6; }
  .mobile-row-toggle { display: flex; margin-top: .45rem; }
}
@media (min-width: 768px) {
  .mobile-row-toggle { display: none; }
}
