html, body {
    margin: 0;
    font-family: "DM Sans", "Segoe UI", sans-serif;
    background: #F3F7FC;
}

.broker-appbar {
    background: linear-gradient(120deg, #0D47A1 0%, #1565C0 55%, #0277BD 100%) !important;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.appbar-logo {
    height: 34px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    margin-right: 10px;
    background: rgba(255,255,255,0.92);
    border-radius: 6px;
    padding: 2px 6px;
}

.appbar-brand {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title {
    font-family: "Instrument Serif", Georgia, serif !important;
    font-weight: 400 !important;
    letter-spacing: 0.02em;
}

.brand-tagline {
    opacity: 0.85;
    color: #E3F2FD !important;
}

.broker-drawer {
    border-right: 1px solid rgba(13, 71, 161, 0.1);
    display: flex;
    flex-direction: column;
}

.broker-main {
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(21, 101, 192, 0.10), transparent 60%),
        radial-gradient(900px 400px at 100% 0%, rgba(2, 119, 189, 0.08), transparent 55%),
        #F3F7FC;
}

.page-hero {
    margin-bottom: 1.5rem;
}

.page-hero h1 {
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    font-size: 2.25rem;
    color: #0D47A1;
    margin: 0 0 0.35rem;
}

.page-hero p {
    color: #5B708B;
    margin: 0;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        linear-gradient(145deg, rgba(13,71,161,0.94), rgba(21,101,192,0.88)),
        radial-gradient(circle at 20% 20%, rgba(0,172,193,0.28), transparent 45%),
        #0D47A1;
}

.login-card {
    width: min(420px, 100%);
    background: rgba(255,255,255,0.97);
    border-radius: 18px;
    padding: 2rem;
    box-shadow: 0 24px 60px rgba(0,0,0,0.28);
}

.login-card h1 {
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    color: #0D47A1;
    margin: 0 0 0.25rem;
}

.login-card .subtitle {
    color: #5B708B;
    margin-bottom: 1.5rem;
}

.login-logo-placeholder {
    height: 56px;
    width: 120px;
    border-radius: 8px;
    background: linear-gradient(90deg, #e8eef5 0%, #f5f7fa 50%, #e8eef5 100%);
    background-size: 200% 100%;
    animation: login-shimmer 1.1s ease-in-out infinite;
}

@keyframes login-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.login-powered {
    margin-top: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #5B708B;
    font-size: 0.85rem;
}

.login-powered img {
    height: 44px;
    width: auto;
    max-width: 240px;
    object-fit: contain;
}

.stat-card {
    background: #fff;
    border: 1px solid rgba(13,71,161,0.08);
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    height: 100%;
    transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(13,71,161,0.12);
}

.stat-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.stat-card .label {
    color: #5B708B;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card .value {
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 2rem;
    color: #0D47A1;
    margin-top: 0.35rem;
}

.mud-table {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.drawer-powered {
    margin-top: auto;
    padding: 1.1rem 1.25rem 1.4rem;
    border-top: 1px solid rgba(13,71,161,0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #5B708B;
    font-size: 0.8rem;
    font-weight: 500;
}

.drawer-powered img {
    height: 48px;
    width: auto;
    max-width: 240px;
    object-fit: contain;
}

.app-footer {
    margin: 2rem 1.5rem 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(13,71,161,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    color: #5B708B;
    font-size: 0.85rem;
}

.footer-powered {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.footer-powered img {
    height: 40px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
}

/* Global data loader */
.global-loader-bar {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3000;
    height: 4px !important;
}

.global-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 2990;
    display: grid;
    place-items: center;
    background: rgba(243, 247, 252, 0.55);
    backdrop-filter: blur(2px);
    pointer-events: all;
}

.global-loader-card {
    background: #fff;
    border: 1px solid rgba(13, 71, 161, 0.12);
    border-radius: 16px;
    padding: 1.75rem 2rem;
    min-width: 220px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(13, 71, 161, 0.14);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}

.global-loader-text {
    font-weight: 600;
    color: #0D47A1;
    font-size: 1.05rem;
}

.global-loader-sub {
    color: #5B708B;
    font-size: 0.85rem;
}

/* Invoice fill cues (same idea as old WinForms; colors are new) */
.inv-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #5B708B;
}

.inv-legend-swatch {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    margin-right: 0.35rem;
    vertical-align: -1px;
    border: 1px solid rgba(0,0,0,0.08);
}

.inv-legend-swatch.premium { background: #FFF3E0; border-color: #FB8C00; }
.inv-legend-swatch.lookup { background: #E3F2FD; border-color: #1565C0; }
.inv-legend-swatch.synced { background: #FFCDD2; border-color: #C62828; }
.inv-legend-swatch.bodily { background: #E8EAF6; border-color: #3949AB; }

.inv-field-premium .mud-input-outlined-border,
.inv-field-premium.mud-input-control .mud-input-outlined .mud-input-outlined-border {
    border-color: #FB8C00 !important;
}

.inv-field-premium .mud-input-slot,
.inv-field-premium input {
    background: #FFF8E1 !important;
    color: #BF360C !important;
    font-weight: 600;
}

.inv-field-lookup .mud-input-outlined-border {
    border-color: #1565C0 !important;
}

.inv-field-lookup .mud-input-slot,
.inv-field-lookup input,
.inv-lookup-chip {
    background: #E3F2FD !important;
    color: #0D47A1 !important;
}

.inv-lookup-chip {
    display: inline-block;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.inv-field-synced .mud-input-outlined-border {
    border-color: #C62828 !important;
}

.inv-field-synced .mud-input-slot,
.inv-field-synced input {
    background: #FFEBEE !important;
    color: #B71C1C !important;
    font-weight: 600;
}

.inv-field-bodily .mud-input-outlined-border {
    border-color: #3949AB !important;
}

.inv-field-bodily .mud-input-slot,
.inv-field-bodily input {
    background: #E8EAF6 !important;
    color: #1A237E !important;
    font-weight: 600;
}

.inv-line-refunded {
    position: relative;
    background: #fff8e6 !important;
}

.inv-line-refunded::after {
    content: "";
    pointer-events: none;
    position: absolute;
    inset: 12px;
    border: 2px solid rgba(198, 40, 40, 0.45);
    border-radius: 10px;
    background:
        linear-gradient(to top left, transparent calc(50% - 1px), rgba(198,40,40,0.55) 50%, transparent calc(50% + 1px)),
        linear-gradient(to top right, transparent calc(50% - 1px), rgba(198,40,40,0.55) 50%, transparent calc(50% + 1px));
    opacity: 0.35;
}

/* Nested child grid under selected master row (statements) */
.child-grid-panel {
    margin: 0 0.5rem 0.75rem 2.25rem;
    padding: 0.85rem 1rem;
    background: #F7FAFE;
    border: 1px solid rgba(13, 71, 161, 0.12);
    border-left: 3px solid #1565C0;
    border-radius: 0 10px 10px 0;
}

.child-grid-table {
    background: #fff;
    border-radius: 8px;
}

tr.child-grid-parent-open > td {
    background: rgba(21, 101, 192, 0.06) !important;
}

/* ?? Client statement printable report ?? */
.statement-print {
    background: #fff;
    border: 1px solid rgba(15,76,92,0.12);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    color: #1a2332;
}

.statement-header {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    border-bottom: 2px solid #0D47A1;
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}

.statement-logo {
    height: 56px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.statement-company {
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 1.6rem;
    color: #0D47A1;
    line-height: 1.2;
}

.statement-title-block {
    margin-left: auto;
    text-align: right;
}

.statement-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: #0D47A1;
}

.statement-meta {
    color: #5B708B;
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.statement-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.statement-table th,
.statement-table td {
    border-bottom: 1px solid #e2e8f0;
    padding: 0.45rem 0.4rem;
    text-align: left;
    vertical-align: top;
}

.statement-table th {
    background: #E3F2FD;
    color: #0D47A1;
    font-weight: 600;
}

.statement-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.statement-pay-row td {
    background: #FFFDE7;
    color: #5D4037;
}

.statement-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 2px solid #0D47A1;
    font-size: 0.95rem;
}

/* Zero @page margin ? Chromium omits date/URL headers & footers when printing. */
@page {
    size: A4;
    margin: 0;
}

@media print {
    .no-print,
    .mud-drawer,
    .mud-appbar,
    .mud-snackbar-provider,
    nav,
    aside {
        display: none !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    body, .broker-main, .mud-main-content, .mud-layout {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .statement-print {
        border: none;
        border-radius: 0;
        padding: 12mm 14mm;
        box-shadow: none;
    }

    .statement-logo {
        display: block !important;
        max-height: 64px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .statement-header {
        display: flex !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .statement-table th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .statement-pay-row td {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ?? Collector / driver mobile-first collect UI ?? */
.collect-page {
    max-width: 560px;
    margin: 0 auto;
    padding-bottom: 6.5rem;
}

.collect-hero {
    margin-bottom: 1rem;
}

.collect-hero h1 {
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    font-size: 1.85rem;
    color: #0D47A1;
    margin: 0 0 0.2rem;
}

.collect-hero p {
    margin: 0;
    color: #5B708B;
    font-size: 0.95rem;
}

.collect-section {
    margin-bottom: 1rem;
}

.collect-section-title {
    font-weight: 600;
    color: #16324F;
    font-size: 0.92rem;
    margin-bottom: 0.5rem;
}

.collect-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.collect-task-scroll {
    display: flex;
    gap: 0.65rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
}

.collect-task-card {
    flex: 0 0 auto;
    width: min(78vw, 240px);
    scroll-snap-align: start;
    text-align: left;
    border: 1px solid rgba(13, 71, 161, 0.14);
    background: #fff;
    border-radius: 14px;
    padding: 0.85rem 1rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(13, 71, 161, 0.04);
}

.collect-task-card.is-active {
    border-color: #1565C0;
    background: #E3F2FD;
}

.collect-task-amt {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0D47A1;
}

.collect-task-amt span {
    font-size: 0.85rem;
    font-weight: 600;
}

.collect-task-name {
    margin-top: 0.25rem;
    font-weight: 600;
    color: #16324F;
    font-size: 0.95rem;
}

.collect-task-meta {
    margin-top: 0.2rem;
    font-size: 0.78rem;
    color: #5B708B;
}

.collect-card {
    background: #fff;
    border: 1px solid rgba(15, 76, 92, 0.08);
    border-radius: 16px;
    padding: 1rem 1rem 1.15rem;
    margin-bottom: 1.25rem;
}

.collect-step {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.65rem;
}

.collect-step-num {
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 50%;
    background: #1565C0;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.collect-step-label {
    font-weight: 600;
    color: #16324F;
}

.collect-optional {
    font-weight: 500;
    color: #5B708B;
    font-size: 0.85em;
}

.collect-field .mud-input-control,
.collect-card .mud-input-control {
    margin-top: 0;
}

.collect-client-chip {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin-top: 0.65rem;
    padding: 0.65rem 0.75rem;
    background: #F3F7FC;
    border-radius: 12px;
    border: 1px solid rgba(13, 71, 161, 0.1);
}

.collect-client-sub {
    font-size: 0.82rem;
    color: #5B708B;
}

.collect-client-sub a {
    color: #1565C0;
    text-decoration: none;
    font-weight: 600;
}

.collect-amount-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
}

.collect-amount-input .mud-input-slot,
.collect-amount-input input {
    font-size: 1.45rem !important;
    font-weight: 700;
    min-height: 3rem;
}

.collect-curr-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.collect-curr-btn {
    min-width: 3.4rem;
    min-height: 2.75rem;
    padding: 0 0.85rem;
    border-radius: 12px;
    border: 1px solid rgba(13, 71, 161, 0.2);
    background: #fff;
    color: #16324F;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
}

.collect-curr-btn.is-on {
    background: #1565C0;
    border-color: #1565C0;
    color: #fff;
}

.collect-receipt-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.collect-gen-btn {
    min-height: 3.25rem !important;
    flex-shrink: 0;
    margin-top: 0;
}

.collect-more {
    background: transparent;
}

.collect-more .mud-expand-panel {
    background: #F8FBFF;
    border-radius: 12px !important;
    border: 1px solid rgba(13, 71, 161, 0.08);
}

.collect-sign-wrap {
    width: 100%;
    position: relative;
    z-index: 2;
}

.collect-sign-canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 180px;
    min-height: 160px;
    border: 2px dashed #90CAF9;
    border-radius: 14px;
    background: #fff;
    touch-action: none !important;
    cursor: crosshair;
    -webkit-user-select: none;
    user-select: none;
}

.collect-save-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(13, 71, 161, 0.12);
    backdrop-filter: blur(8px);
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

.collect-save-summary {
    display: flex;
    flex-direction: column;
    font-size: 0.92rem;
    font-weight: 700;
    color: #0D47A1;
}

.collect-save-client {
    font-weight: 500;
    font-size: 0.8rem;
    color: #5B708B;
}

.collect-save-btn {
    min-height: 3.1rem !important;
    font-size: 1.05rem !important;
    font-weight: 700 !important;
}

.collect-history {
    margin-top: 0.5rem;
}

.collect-filter-row {
    margin-bottom: 0.75rem;
    overflow-x: auto;
}

.collect-empty {
    text-align: center;
    color: #5B708B;
    padding: 1.5rem 1rem;
    background: #fff;
    border-radius: 14px;
    border: 1px dashed rgba(13, 71, 161, 0.2);
}

.collect-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.collect-hist-card {
    background: #fff;
    border: 1px solid rgba(15, 76, 92, 0.08);
    border-radius: 14px;
    padding: 0.85rem 1rem;
}

.collect-hist-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.collect-hist-amt {
    margin-top: 0.35rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0D47A1;
}

.collect-hist-left {
    font-size: 0.8rem;
    font-weight: 500;
    color: #F9A825;
}

.collect-hist-name {
    font-weight: 600;
    color: #16324F;
    margin-top: 0.15rem;
}

.collect-hist-meta {
    font-size: 0.78rem;
    color: #5B708B;
    margin-top: 0.15rem;
}

.collect-hist-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.35rem;
}

.cash-qr-wrap {
    text-align: center;
    padding: 0.75rem 0 0.25rem;
}

.cash-qr-img {
    width: min(72vw, 260px);
    height: auto;
    image-rendering: pixelated;
    border: 1px solid rgba(13, 71, 161, 0.12);
    border-radius: 12px;
    background: #fff;
    padding: 0.5rem;
}

.cash-qr-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: #0D47A1;
    margin: 0.5rem 0 0.15rem;
}

.cash-qr-reader {
    width: 100%;
    min-height: 40px;
    overflow: hidden;
    border-radius: 12px;
}

.cash-qr-reader video {
    border-radius: 12px;
}

.cash-voucher-print {
    background: #fff;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(15, 76, 92, 0.1);
    border-radius: 12px;
}

.cash-voucher-print h2 {
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    color: #0D47A1;
    margin: 0 0 0.5rem;
}

.cash-voucher-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0.75rem 0;
}

.cash-voucher-table th,
.cash-voucher-table td {
    border-bottom: 1px solid #e6ebf2;
    padding: 0.35rem 0.25rem;
    text-align: left;
}

.cash-voucher-table .num {
    text-align: right;
    white-space: nowrap;
}

.cash-voucher-totals {
    margin: 0.75rem 0 1rem;
    font-size: 1rem;
}

.cash-voucher-sigs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid #d7dee8;
}

.cash-voucher-sig-label {
    font-size: 0.75rem;
    color: #5B708B;
    margin-bottom: 0.25rem;
}

.cash-voucher-sigs img {
    max-width: 100%;
    height: 64px;
    object-fit: contain;
    display: block;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid #c5d0de;
}

@media (min-width: 900px) {
    .collect-page {
        max-width: 640px;
        padding-bottom: 2rem;
    }

    .collect-save-bar {
        position: static;
        border: none;
        background: transparent;
        padding: 0;
        margin-top: 0.75rem;
        backdrop-filter: none;
    }

    .collect-amount-row {
        grid-template-columns: 1.4fr auto;
        align-items: end;
    }
}

/* Reduce main container side padding on phones for this flow */
@media (max-width: 600px) {
    .broker-main .mud-container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}
