:root {
    color-scheme: light;
    --app-bg: #f4f7fb;
    --surface: #ffffff;
    --ink: #17243a;
    --muted: #6d7b91;
    --line: #e5eaf1;
    --brand: #2859d6;
    --brand-dark: #1e45ae;
    --success: #16845b;
    --danger: #c63e4b;
    --radius: 16px;
    --shadow: 0 8px 28px rgba(28, 48, 84, .07);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

.container-fluid > header {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 78px;
    padding: 12px 28px !important;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line) !important;
    box-shadow: 0 3px 14px rgba(28, 48, 84, .035);
    backdrop-filter: blur(12px);
}

.container-fluid > header img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 12px;
}

.container-fluid > header span {
    color: var(--ink);
    font-size: 1rem !important;
}

.container-fluid > header a {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    border-radius: 12px;
    background: #f2f5fa;
    color: var(--muted);
    text-decoration: none;
    transition: background .18s ease, color .18s ease;
}

.container-fluid > header a:hover {
    background: #fff0f0;
    color: var(--danger);
}

.container-fluid > .row {
    min-height: calc(100vh - 78px);
    margin: 0;
}

.container-fluid > .row > .col-lg-2 {
    flex: 0 0 250px;
    max-width: 250px;
    padding: 24px 16px !important;
    background: var(--surface) !important;
    border-right: 1px solid var(--line);
}

.container-fluid > .row > .col-lg-10 {
    width: calc(100% - 250px);
    padding: 32px !important;
}

.nav-pills .nav-link {
    margin: 4px 0;
    padding: 11px 13px;
    border-radius: 11px;
    color: #53627a;
    font-weight: 550;
    transition: background .18s ease, color .18s ease;
}

.nav-pills .nav-link:hover {
    background: #f3f6fc;
    color: var(--brand);
}

.nav-pills .nav-link.active {
    background: #eaf0ff;
    color: var(--brand);
    font-weight: 650;
}

.nav-pills .nav-link i {
    width: 20px;
    text-align: center;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--ink);
    letter-spacing: -.025em;
}

h2 {
    margin: 0 0 18px;
    font-size: clamp(1.45rem, 2vw, 1.8rem);
    font-weight: 720;
}

hr.border-primary {
    border-color: var(--line) !important;
    border-width: 1px !important;
    opacity: 1;
}

.table {
    overflow: hidden;
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: 13px 14px;
    border-bottom-color: var(--line);
}

.table thead th {
    background: #f7f9fc;
    color: #66758c;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table-hover > tbody > tr:hover > * {
    background: #f8faff;
}

.form-control, .form-select {
    min-height: 44px;
    border-color: #dce3ed;
    border-radius: 10px;
    color: var(--ink);
    box-shadow: none;
}

.form-control:focus, .form-select:focus {
    border-color: #89a7f4;
    box-shadow: 0 0 0 4px rgba(40, 89, 214, .12);
}

.form-label {
    margin-bottom: 7px;
    color: #47566e;
    font-size: .88rem;
    font-weight: 650;
}

.btn {
    min-height: 40px;
    padding: 9px 15px;
    border-radius: 10px;
    font-weight: 650;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    border-color: var(--brand);
    background: var(--brand);
    box-shadow: 0 4px 10px rgba(40, 89, 214, .18);
}

.btn-primary:hover {
    border-color: var(--brand-dark);
    background: var(--brand-dark);
}

.alert {
    border: 0;
    border-radius: 12px;
}

.form-signin {
    max-width: 420px !important;
    padding: 38px !important;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 18px 55px rgba(28, 48, 84, .12);
}

.container-sm:has(.form-signin) {
    min-height: 100vh;
    max-width: none;
    justify-content: center;
    background: radial-gradient(ellipse at top left, #e9efff 0, transparent 46%), var(--app-bg) !important;
}

.form-signin img {
    display: block;
    width: auto;
    max-width: 120px;
    max-height: 70px;
    margin: 0 auto 24px;
    object-fit: contain;
}

.form-signin h1 {
    margin-bottom: 24px !important;
    text-align: center;
    font-weight: 750;
}

.form-signin .form-floating {
    margin-bottom: 12px;
}

.form-signin .btn {
    margin-top: 8px;
}

@media (max-width: 991.98px) {
    .container-fluid > .row > .col-lg-2 {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 10px 16px !important;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .container-fluid > .row > .col-lg-10 {
        width: 100%;
        padding: 22px 18px !important;
    }

    .container-fluid > .row > .col-lg-2 > a:first-child,
    .container-fluid > .row > .col-lg-2 > hr {
        display: none;
    }

    .nav-pills {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 4px;
    }

    .nav-pills .nav-link {
        margin: 0;
        padding: 9px 11px;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (max-width: 575.98px) {
    .container-fluid > header {
        min-height: 66px;
        padding: 10px 14px !important;
    }

    .container-fluid > header img {
        width: 40px;
        height: 40px;
    }

    .container-fluid > header span {
        font-size: .9rem !important;
    }

    .form-signin {
        padding: 28px 22px !important;
    }
}

/* Invoice totals summary cards */
.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) {
    width: min(100%, 520px);
    margin: 12px 0 0 auto !important;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-9 {
    display: none;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-2,
.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-1 {
    display: flex;
    width: 50%;
    flex: 0 0 50%;
    align-items: center;
    padding: 14px 18px !important;
    background: transparent !important;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-2 {
    color: var(--muted) !important;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-2 b {
    font-size: .82rem !important;
    font-weight: 700;
    letter-spacing: .04em;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-1 {
    justify-content: flex-end;
    color: var(--ink) !important;
    text-align: right;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-1 span {
    font-size: 1.15rem !important;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) + .row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) {
    margin-top: 0 !important;
    border-top: 0;
    border-radius: 0;
    box-shadow: none;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1):last-of-type {
    margin-bottom: 12px !important;
    border-radius: 0 0 14px 14px;
}

@media (max-width: 575.98px) {
    .row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) {
        width: 100%;
    }
}

/* Fix contrast and spacing for the invoice summary cards */
.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) {
    margin-top: 10px !important;
    border-radius: 14px !important;
    box-shadow: var(--shadow) !important;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) + .row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) {
    margin-top: 10px !important;
    border: 1px solid var(--line) !important;
    border-radius: 14px !important;
    box-shadow: var(--shadow) !important;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-2 b {
    color: var(--muted) !important;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-1 span {
    color: var(--ink) !important;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-2.bg-primary b {
    color: var(--brand) !important;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-2.bg-success b {
    color: var(--success) !important;
}

.row:has(> .col-lg-9 + .col-lg-2 + .col-lg-1) > .col-lg-2.bg-danger b {
    color: var(--danger) !important;
}

.column-order-cell { display: flex; align-items: center; gap: 10px; min-width: 72px; }
.drag-handle { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 30px; color: #8290a5; cursor: grab; user-select: none; font-size: 1.35rem; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
#invoice-columns tr.is-dragging { opacity: .45; }
#invoice-columns tr { transition: background-color .15s ease, opacity .15s ease; }
#invoice-columns tr:hover .drag-handle { color: var(--brand); }

#invoice-list-container { transition: opacity .18s ease; }
#invoice-list-container.is-loading { opacity: .55; pointer-events: none; }

.invoice-view-page { min-height: 100vh; padding: 24px; background: #eef2f8; }
.invoice-toolbar { width: min(100%, 1040px); margin: 0 auto 16px; display: flex; justify-content: space-between; }
.invoice-paper { width: min(100%, 1040px); margin: 0 auto; padding: 54px 60px 36px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 18px 50px rgba(28,48,84,.10); }
.invoice-brand-header { display: flex; justify-content: space-between; gap: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.invoice-brand { display: flex; align-items: center; gap: 18px; }
.invoice-brand img { width: 82px; height: 82px; object-fit: contain; }
.invoice-brand h1 { margin: 0; font-size: 1.5rem; font-weight: 750; }
.invoice-eyebrow { margin-bottom: 7px; color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.invoice-contact { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 5px; color: var(--muted); font-size: .82rem; text-align: right; }
.invoice-contact a { color: var(--brand); text-decoration: none; }
.invoice-title-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 30px 0 24px; }
.invoice-title-row h2 { margin: 0; font-size: 1.8rem; font-weight: 760; }
.invoice-status { display: inline-flex; align-items: center; padding: 9px 14px; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.invoice-status.is-paid { background: #e8f7ef; color: var(--success); }
.invoice-status.is-pending { background: #fff4dd; color: #9a6800; }
.invoice-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 28px; }
.invoice-info-card { padding: 20px 22px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfe; }
.invoice-info-card h3 { margin: 0 0 7px; font-size: 1.05rem; font-weight: 700; }
.invoice-info-card p { margin: 0; color: var(--muted); }
.invoice-details { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.invoice-details div { display: flex; flex-direction: column; gap: 4px; }
.invoice-details span { color: var(--muted); font-size: .76rem; }
.invoice-details b { font-size: .88rem; }
.invoice-lines-wrap { margin-bottom: 28px; }
.invoice-lines { margin: 0; border-radius: 12px; box-shadow: none; }
.invoice-lines thead th { padding: 13px 14px; background: #f3f6fb; }
.invoice-lines tbody td { padding: 14px; }
.invoice-bottom-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; align-items: start; }
.invoice-bank-card, .invoice-total-card { padding: 21px; border: 1px solid var(--line); border-radius: 13px; }
.invoice-bank-card { background: #fbfcfe; }
.invoice-bank-card dl { display: grid; grid-template-columns: 145px 1fr; gap: 9px 12px; margin: 14px 0 0; font-size: .77rem; }
.invoice-bank-card dt { color: var(--muted); font-weight: 600; }
.invoice-bank-card dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.invoice-total-card { padding: 8px 20px; }
.invoice-total-line, .invoice-grand-total { display: flex; justify-content: space-between; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.invoice-total-line span { color: var(--muted); }
.invoice-grand-total { align-items: center; border: 0; color: var(--brand); font-weight: 750; }
.invoice-grand-total strong { font-size: 1.35rem; white-space: nowrap; }
.invoice-footer { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; text-align: center; }
@media (max-width: 767.98px) {
    .invoice-view-page { padding: 12px; }
    .invoice-paper { padding: 28px 22px; }
    .invoice-brand-header, .invoice-title-row { align-items: flex-start; flex-direction: column; }
    .invoice-contact { align-items: flex-start; text-align: left; }
    .invoice-meta-grid, .invoice-bottom-grid { grid-template-columns: 1fr; }
    .invoice-bank-card dl { grid-template-columns: 1fr; gap: 3px; }
    .invoice-bank-card dd { margin-bottom: 9px; }
}
@media print {
    @page { size: 297mm 210mm; margin: 10mm; }
    body.invoice-view-page { padding: 0; background: #fff; }
    .invoice-toolbar { display: none !important; }
    .invoice-paper { width: 100%; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
    .invoice-brand-header { gap: 12px; padding-bottom: 10px; }
    .invoice-brand img { width: 58px; height: 58px; }
    .invoice-title-row { padding: 12px 0 10px; }
    .invoice-title-row h2 { font-size: 1.35rem; }
    .invoice-meta-grid { grid-template-columns: 1fr 1.2fr; gap: 10px; margin-bottom: 12px; }
    .invoice-info-card { padding: 10px 14px; }
    .invoice-lines-wrap { margin-bottom: 12px; }
    .invoice-lines thead th, .invoice-lines tbody td { padding: 6px 9px; }
    .invoice-bottom-grid { gap: 12px; }
    .invoice-bank-card { padding: 12px; }
    .invoice-bank-card dl { display: grid !important; grid-template-columns: 105px minmax(0, 1fr) !important; gap: 3px 8px !important; margin-top: 6px; font-size: .68rem; line-height: 1.15; }
    .invoice-bank-card dt, .invoice-bank-card dd { margin: 0 !important; }
    .invoice-total-card { padding: 4px 12px; }
    .invoice-total-line, .invoice-grand-total { padding: 8px 0; }
    .invoice-footer { margin-top: 10px; padding-top: 8px; }
    .invoice-bottom-grid { grid-template-columns: 1.2fr .8fr !important; }
    .invoice-bank-card, .invoice-total-card, .invoice-info-card { break-inside: avoid; }
    .invoice-lines thead { display: table-header-group; }
    .invoice-lines tr { break-inside: avoid; }
    .invoice-brand-header, .invoice-title-row, .invoice-meta-grid, .invoice-bottom-grid, .invoice-info-card, .invoice-bank-card, .invoice-total-card { break-inside: avoid; }
    .invoice-lines { box-shadow: none; }
}

.invoice-toolbar-actions { display: flex; gap: 10px; }
.invoice-pdf-link { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: #fff0f0; color: #c63e4b; text-decoration: none; }
.invoice-pdf-link:hover { background: #c63e4b; color: #fff; }







.invoice-bulk-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.invoice-bulk-toolbar label { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: .9rem; }
.invoice-bulk-form .invoice-row-select, .invoice-bulk-form .invoice-select-all { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.invoice-bulk-delete:disabled { opacity: .5; cursor: not-allowed; }
