:root {
    --blue-900: #0b2f66;
    --blue-700: #1557b0;
    --blue-500: #2777e6;
    --blue-100: #eaf3ff;
    --line: #d9e4f2;
    --ink: #16233a;
    --muted: #6b7a90;
    --surface: #ffffff;
    --page: #f5f9ff;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: var(--page);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.app-topbar .container-fluid {
    min-height: 72px;
    display: flex;
    align-items: center;
}

.topbar-inner,
.brand-lockup,
.topbar-actions,
.toolbar,
.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-inner {
    width: 100%;
    justify-content: space-between;
}

.brand-lockup {
    color: var(--ink);
    text-decoration: none;
    flex: 0 0 auto;
}

.brand-lockup:hover {
    color: var(--ink);
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--blue-900);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0;
}

.module-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbff;
}

.module-nav a {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0 0.75rem;
    border-radius: 6px;
    color: #53647b;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
}

.module-nav a.active,
.module-nav a:hover {
    color: var(--blue-900);
    background: #fff;
    box-shadow: 0 2px 12px rgba(21, 87, 176, 0.12);
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-title h2 {
    margin: 0;
    font-size: clamp(1.6rem, 2.6vw, 2.15rem);
    font-weight: 850;
}

.eyebrow,
.metric-label {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.btn {
    border-radius: 8px;
    font-weight: 700;
}

.btn i {
    margin-right: 0.35rem;
}

.btn-sm {
    min-height: 34px;
}

.btn-primary {
    background: var(--blue-700);
    border-color: var(--blue-700);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--blue-900);
    border-color: var(--blue-900);
}

.btn-outline-primary {
    border-color: var(--blue-500);
    color: var(--blue-700);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: var(--blue-700);
    border-color: var(--blue-700);
}

.summary-grid,
.cash-grid {
    display: grid;
    gap: 1rem;
}

.summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 1rem;
}

.metric-card,
.cash-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 40px rgba(21, 87, 176, 0.06);
}

.metric-card {
    min-height: 104px;
    padding: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.metric-card strong,
.cash-card strong {
    display: block;
    font-size: clamp(1.35rem, 2vw, 1.8rem);
    line-height: 1.1;
}

.metric-card i {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: 1.2rem;
}

.panel {
    padding: 1rem;
}

.dashboard-panel {
    min-height: 270px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-heading h2,
.drop-zone h3,
.example-box h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
}

.quick-actions,
.status-list {
    display: grid;
    gap: 0.8rem;
}

.quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-action {
    min-height: 152px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.45rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    color: var(--ink);
    text-decoration: none;
}

.quick-action:hover {
    border-color: #a9c6ed;
    color: var(--ink);
    box-shadow: 0 10px 28px rgba(21, 87, 176, 0.1);
}

.quick-action i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: 1.25rem;
}

.quick-action span {
    font-weight: 850;
}

.quick-action small {
    color: var(--muted);
    line-height: 1.35;
}

.status-list div {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #edf2f8;
}

.status-list div:last-child {
    border-bottom: 0;
}

.status-list span {
    color: #34445e;
    font-weight: 700;
}

.status-list strong {
    color: var(--blue-900);
    font-size: 1.35rem;
}

.segmented-tabs {
    padding: 0.25rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbff;
}

.segmented-tabs button {
    min-height: 40px;
    border: 0;
    border-radius: 6px;
    padding: 0 0.85rem;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
}

.segmented-tabs button.active {
    color: var(--blue-900);
    background: #fff;
    box-shadow: 0 2px 12px rgba(21, 87, 176, 0.12);
}

.form-label {
    color: #34445e;
    font-size: 0.84rem;
    font-weight: 700;
}

.form-control,
.form-select,
.input-group-text {
    border-color: var(--line);
    border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 0.2rem rgba(39, 119, 230, 0.14);
}

.total-field {
    color: var(--blue-900);
    font-weight: 800;
    background: var(--blue-100);
}

.lookup-status {
    min-height: 1.2rem;
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.lookup-status.success {
    color: #168553;
}

.lookup-status.error {
    color: #b42318;
}

.upload-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
    gap: 1rem;
}

.drop-zone,
.example-box {
    min-height: 260px;
    border: 1px dashed #b9cce5;
    border-radius: 8px;
    background: #fbfdff;
    padding: 1.25rem;
}

.drop-zone {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

.drop-zone > i {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    margin-bottom: 1rem;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: 1.8rem;
}

.drop-zone p {
    color: var(--muted);
    max-width: 34rem;
}

.xml-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    display: grid;
    gap: 0.65rem;
}

.xml-list li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #34445e;
    font-weight: 700;
}

.xml-list i {
    color: var(--blue-700);
}

.search-box {
    width: min(360px, 48vw);
}

.table {
    margin-bottom: 0;
}

.invoice-table {
    min-width: 1320px;
}

.table thead th {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    background: #f8fbff;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    border-color: #edf2f8;
}

.invoice-table td strong,
.invoice-table td span {
    display: block;
}

.invoice-table td:nth-child(4),
.invoice-table td:nth-child(5),
.invoice-table td:nth-child(6) {
    white-space: nowrap;
}

.invoice-table .form-select {
    min-width: 170px;
}

.invoice-table td span:not(.badge):not(.source-pill) {
    color: var(--muted);
    font-size: 0.84rem;
}

.source-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 0.65rem;
    border-radius: 999px;
    background: var(--blue-100);
    color: var(--blue-900);
    font-weight: 800;
    font-size: 0.78rem;
}

.action-buttons .btn {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    color: var(--blue-700);
    border: 1px solid var(--line);
}

.action-buttons .btn i {
    margin: 0;
}

.action-buttons form {
    margin: 0;
}

.panel-subheading {
    margin-bottom: 0.85rem;
}

.panel-subheading h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 850;
}

.cash-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cash-card {
    padding: 1rem;
}

.cash-values {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 1rem 0 0.7rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.cash-values b {
    color: var(--ink);
}

.progress {
    height: 0.7rem;
    background: #e9f1fb;
    border-radius: 999px;
}

.modal-content {
    border: 0;
    border-radius: 8px;
}

@media (max-width: 1100px) {
    .summary-grid,
    .cash-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar-inner {
        flex-wrap: wrap;
    }

    .module-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
    }

    .dashboard-grid,
    .upload-layout {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-topbar .container-fluid,
    .panel-heading,
    .toolbar {
        align-items: stretch;
    }

    .topbar-inner,
    .panel-heading,
    .toolbar {
        flex-direction: column;
    }

    .topbar-actions,
    .module-nav,
    .segmented-tabs,
    .toolbar,
    .search-box {
        width: 100%;
    }

    .topbar-actions .btn,
    .module-nav a,
    .segmented-tabs button,
    .toolbar .btn,
    .toolbar .form-select {
        flex: 1;
    }

    .module-nav {
        display: grid;
        grid-template-columns: 1fr;
    }

    .segmented-tabs {
        display: grid;
        grid-template-columns: 1fr;
    }

    .summary-grid,
    .cash-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 0.85rem;
    }

    .cash-values {
        flex-direction: column;
    }
}
