html {
    font-size: 15px;
    max-width: 100%;
    scroll-behavior: smooth;
}

body {
    background: #f4f7fb;
    color: #1f2937;
    font-size: 0.98rem;
    line-height: 1.45;
    max-width: 100%;
    overflow-x: hidden;
}

.app-body {
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    width: 300px;
    background: linear-gradient(180deg, #0f172a 0%, #162338 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.18);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
}

.app-sidebar-header {
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    padding: 1.1rem 1.25rem;
}

.app-sidebar-body {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.app-sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 100%;
    padding: 1rem;
    width: 100%;
}

.app-brand {
    color: #f8fafc;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.app-brand:hover {
    color: #ffffff;
}

.app-eyebrow {
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.sidebar-nav-root {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
}

.app-sidebar .nav-item {
    width: 100%;
}

.app-sidebar .nav-link,
.app-sidebar .dropdown-item {
    border-radius: 12px;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.7rem 0.9rem;
    white-space: normal;
}

.app-sidebar .nav-link:hover,
.app-sidebar .dropdown-item:hover,
.app-sidebar .nav-link:focus,
.app-sidebar .dropdown-item:focus {
    background: rgba(59, 130, 246, 0.18);
    color: #f8fafc;
}

.app-sidebar .nav-link.active,
.app-sidebar .dropdown-item.active {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
}

.app-sidebar .dropdown-toggle::after {
    margin-left: auto;
    transition: transform 0.18s ease;
}

.app-sidebar .dropdown-menu {
    background: transparent;
    border: 0;
    box-shadow: none;
    display: none;
    margin: 0.2rem 0 0.55rem;
    min-width: 100%;
    padding: 0.15rem 0 0.15rem 1rem;
    position: static;
    transform: none !important;
}

.app-sidebar .dropdown-menu.show {
    display: block;
}

.app-sidebar .dropdown-item {
    font-size: 0.93rem;
    padding-left: 1rem;
}

.app-sidebar .dropdown-toggle {
    cursor: pointer;
    justify-content: space-between;
}

.app-sidebar .dropdown-toggle.active::after,
.app-sidebar .dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

.app-sidebar .dropdown-divider {
    border-color: rgba(148, 163, 184, 0.16);
}

.app-sidebar .dropdown-header {
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    padding: 0.55rem 0.9rem 0.35rem;
    text-transform: uppercase;
}

.app-sidebar .navbar-nav:last-child {
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    margin-top: auto;
    padding-top: 1rem;
}

.app-sidebar .navbar-nav:last-child .nav-link {
    color: #e2e8f0;
}

.app-main {
    min-height: 100vh;
}

.app-topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-nav-toggle {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    color: #0f172a;
    display: none;
    font-size: 1.15rem;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.app-nav-toggle:hover,
.app-nav-toggle:focus {
    background: #eff6ff;
    color: #1d4ed8;
}

.app-sidebar-backdrop {
    display: none;
}

.app-page-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0.2rem 0 0;
}

h1, .h1 {
    font-size: 1.75rem;
}

h2, .h2 {
    font-size: 1.5rem;
}

h3, .h3 {
    font-size: 1.28rem;
}

h4, .h4 {
    font-size: 1.12rem;
}

h5, .h5 {
    font-size: 1rem;
}

h6, .h6 {
    font-size: 0.94rem;
}

.table {
    font-size: 0.95rem;
}

.table-responsive {
    position: static;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .table th,
.card-body.p-0 > .table th,
.card-body.p-0 .table th {
    background: #f8fafc;
    position: static;
    top: auto;
    z-index: auto;
    box-shadow: inset 0 -1px 0 rgba(148, 163, 184, 0.18);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.15;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
    vertical-align: middle;
}

.table-responsive .table thead th,
.card-body.p-0 > .table thead th,
.card-body.p-0 .table thead th {
    z-index: auto;
}

.table-responsive .table th a,
.card-body.p-0 > .table th a,
.card-body.p-0 .table th a {
    color: inherit;
}

.normal-grid-headers .table th,
.normal-grid-headers .table thead th {
    position: static;
    top: auto;
    z-index: auto;
    box-shadow: none;
    white-space: normal;
}

.report-masthead {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.06);
    padding: 1.5rem 1.65rem;
}

.report-masthead__identity {
    align-items: flex-start;
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;
}

.report-eyebrow {
    color: #0f766e;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    margin-bottom: 0.45rem;
    text-transform: uppercase;
}

.report-title {
    color: #0f172a;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    margin: 0;
}

.report-subtitle {
    color: #475569;
    margin: 0.55rem 0 0;
    max-width: 60rem;
}

.report-meta {
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 0.75rem;
}

.report-logo {
    height: auto;
    max-width: 170px;
    object-fit: contain;
    width: 170px;
}

.report-actionbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    margin-top: 1.25rem;
}

.report-surface {
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

.report-kpi-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 16px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
    height: 100%;
}

.report-kpi-label {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.report-kpi-value {
    color: #0f172a;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 0.35rem;
}

.report-kpi-note {
    color: #64748b;
    font-size: 0.88rem;
    margin-top: 0.45rem;
}

.report-card-header {
    background: #fff;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    padding: 1.05rem 1.25rem 0.95rem;
}

.report-card-title {
    color: #0f172a;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.12rem;
    font-weight: 700;
    margin: 0;
}

.report-card-subtitle {
    color: #64748b;
    font-size: 0.92rem;
    margin: 0.3rem 0 0;
}

.report-highlight-note {
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    color: #334155;
    padding: 0.85rem 1rem;
}

.sales-app-nav {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    position: sticky;
    top: 75px;
    z-index: 19;
}

.sales-app-nav__inner {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.65rem 1.25rem;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.sales-app-link {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    color: #475569;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.9rem;
    font-weight: 700;
    gap: 0.45rem;
    min-height: 42px;
    padding: 0.55rem 0.8rem;
    text-decoration: none;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, transform 0.18s ease;
    white-space: nowrap;
}

.sales-app-link i {
    color: #0f766e;
    font-size: 1rem;
    line-height: 1;
}

.sales-app-link:hover,
.sales-app-link:focus {
    border-color: rgba(15, 118, 110, 0.38);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    color: #0f172a;
    transform: translateY(-1px);
}

.sales-app-link.active {
    background: #0f172a;
    border-color: #0f172a;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.16);
    color: #ffffff;
}

.sales-app-link.active i {
    color: #5eead4;
}

.sales-bottom-tabs {
    display: none;
}

.sales-app-active .sales-mobile-tabs {
    display: none !important;
}

.sales-anchor-offset {
    display: block;
    height: 0;
    scroll-margin-top: 8.5rem;
}

@media (max-width: 991.98px) {
    .report-masthead__identity {
        flex-direction: column-reverse;
    }

    .report-title {
        font-size: 1.5rem;
    }

    .report-logo {
        width: 140px;
    }

    .sales-app-nav {
        display: none;
    }

    .sales-app-body-content {
        padding-bottom: calc(7.4rem + env(safe-area-inset-bottom));
    }

    .sales-bottom-tabs {
        align-items: center;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
        border: 1px solid rgba(148, 163, 184, 0.26);
        border-bottom: 0;
        border-radius: 24px 24px 0 0;
        bottom: 0;
        box-shadow: 0 -18px 38px rgba(15, 23, 42, 0.16);
        display: grid;
        gap: 0.22rem;
        grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
        left: 50%;
        max-width: 640px;
        padding: 0.55rem 0.55rem calc(0.62rem + env(safe-area-inset-bottom));
        position: fixed;
        transform: translateX(-50%);
        width: min(100%, 640px);
        z-index: 1040;
        backdrop-filter: blur(18px);
    }

    .sales-bottom-tab,
    .sales-bottom-tab:link,
    .sales-bottom-tab:visited {
        align-items: center;
        appearance: none;
        background: transparent;
        border: 0;
        border-radius: 18px;
        color: #475569;
        display: inline-flex;
        flex-direction: column;
        font-size: 0.58rem;
        font-weight: 800;
        gap: 0.18rem;
        justify-content: center;
        letter-spacing: 0;
        min-height: 64px;
        min-width: 0;
        padding: 0.24rem 0.16rem;
        text-decoration: none;
        transition: background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, transform 0.18s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .sales-bottom-tab i {
        align-items: center;
        background: #e0f2fe;
        border: 1px solid rgba(14, 116, 144, 0.12);
        border-radius: 999px;
        color: #0f766e;
        display: inline-flex;
        font-size: 1.08rem;
        height: 2rem;
        justify-content: center;
        line-height: 1;
        width: 2rem;
    }

    .sales-bottom-tab span {
        line-height: 1.08;
        max-width: 100%;
        overflow: hidden;
        text-align: center;
        text-decoration: none;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sales-bottom-tab.active,
    .sales-bottom-tab:hover,
    .sales-bottom-tab:focus {
        background: #0f172a;
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.2);
        color: #ffffff;
        outline: none;
        transform: translateY(-2px);
    }

    .sales-bottom-tab.active i,
    .sales-bottom-tab:hover i,
    .sales-bottom-tab:focus i {
        background: #14b8a6;
        border-color: rgba(94, 234, 212, 0.5);
        color: #ffffff;
    }
}

@media (max-width: 767.98px) {
    .sales-app-active .app-topbar {
        padding: 0.75rem 0.85rem;
    }

    .sales-app-active .app-page-title {
        font-size: 1.05rem;
        line-height: 1.2;
    }

    .sales-app-active .app-eyebrow {
        font-size: 0.64rem;
    }

    .sales-app-body-content {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }
}

.form-control,
.form-select,
.btn,
.form-label,
.dropdown-menu,
.alert,
.card-body,
.card-header {
    font-size: 0.95rem;
}

.body-content {
    padding: 1.25rem;
}

.body-content-auth {
    margin: 0 auto;
    max-width: 880px;
    padding: 2.5rem 1.25rem;
}

.body-content .container,
.body-content .container-fluid {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

.app-footer {
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    color: #64748b;
    margin-top: 1.5rem;
    padding: 1rem 0 0;
}

.dl-horizontal dt {
    white-space: normal;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="select"] {
    max-width: 280px;
}

@media (min-width: 992px) {
    .app-shell {
        display: grid;
        grid-template-columns: 300px minmax(0, 1fr);
    }

    .app-shell-auth {
        display: block;
    }

    .app-sidebar {
        display: flex;
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }

    .app-sidebar .offcanvas-header {
        display: flex;
    }

    .app-main {
        min-width: 0;
    }
}

@media (max-width: 991.98px) {
    html,
    body {
        overflow-x: hidden;
    }

    .app-shell {
        display: block;
    }

    .app-sidebar {
        bottom: 0;
        height: 100vh;
        left: 0;
        max-width: 88vw;
        position: fixed;
        top: 0;
        transform: translateX(-104%);
        transition: transform 0.22s ease;
        width: 300px;
        z-index: 50;
        overflow-y: auto;
        box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
    }

    .app-shell.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-sidebar-backdrop {
        background: rgba(15, 23, 42, 0.44);
        bottom: 0;
        display: block;
        left: 0;
        opacity: 0;
        pointer-events: none;
        position: fixed;
        right: 0;
        top: 0;
        transition: opacity 0.2s ease;
        z-index: 40;
    }

    .app-shell.sidebar-open .app-sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .app-nav-toggle {
        display: inline-flex;
    }

    .body-content {
        padding: 1rem;
    }

    .container,
    .container-fluid {
        padding-left: 0.9rem;
        padding-right: 0.9rem;
    }

    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    .form-control,
    .form-select,
    .btn,
    .input-group-text {
        min-height: 44px;
    }

    .report-masthead__identity,
    .report-actionbar,
    .income-statement-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .report-logo,
    .income-statement-logo {
        max-width: 180px;
    }

    body.sidebar-locked {
        overflow: hidden;
    }

    :root {
        --app-sticky-table-top: 52px;
    }
}

@media (max-width: 991.98px) {
    .sales-app-active .body-content {
        background: #f6f8fb;
        padding-top: 0;
    }

    .sales-app-active .body-content > .container.py-4,
    .sales-app-active .body-content > .container-fluid.py-4 {
        padding-top: 0 !important;
    }

    .sales-app-active .report-masthead {
        background:
            linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(17, 94, 89, 0.96) 64%, rgba(20, 184, 166, 0.9) 100%);
        border: 0;
        border-radius: 0 0 22px 22px;
        box-shadow: 0 18px 34px rgba(15, 23, 42, 0.18);
        color: #fff;
        margin: 0 -0.85rem 1rem;
        padding: 1.15rem 1rem 1.05rem;
    }

    .sales-app-active .report-masthead__identity {
        align-items: flex-start;
        flex-direction: row;
        gap: 0.8rem;
    }

    .sales-app-active .report-eyebrow {
        color: #99f6e4;
        font-size: 0.68rem;
        letter-spacing: 0.08em;
        margin-bottom: 0.25rem;
    }

    .sales-app-active .report-title {
        color: #fff;
        font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
        font-size: 1.65rem;
        letter-spacing: 0;
        line-height: 1.05;
    }

    .sales-app-active .report-subtitle,
    .sales-app-active .report-meta {
        color: rgba(255, 255, 255, 0.78);
    }

    .sales-app-active .report-logo {
        background: rgba(255, 255, 255, 0.92);
        border-radius: 12px;
        max-width: 92px;
        padding: 0.35rem;
        width: 92px;
    }

    .sales-request-entry-page .report-logo,
    .sales-cash-deposit-page .report-logo,
    .basic-request-page .report-logo {
        display: none;
    }

    .sales-app-active .report-actionbar {
        align-items: stretch;
        display: grid;
        gap: 0.55rem;
        grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
        margin-top: 0.9rem;
        width: 100%;
    }

    .sales-app-active .report-actionbar .btn {
        align-items: center;
        border-radius: 14px;
        display: inline-flex;
        font-weight: 800;
        justify-content: center;
        min-height: 46px;
    }

    .sales-app-active .report-actionbar .btn-outline-secondary,
    .sales-app-active .report-actionbar .btn-outline-dark {
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.45);
        color: #fff;
    }

    .sales-app-active .report-surface,
    .sales-app-active .report-kpi-card {
        border-color: #e2e8f0;
        border-radius: 16px;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
    }

    .sales-app-active .form-control,
    .sales-app-active .form-select,
    .sales-app-active .btn {
        border-radius: 12px;
    }

    .sales-app-active .row.g-3.mb-4 {
        row-gap: 0.75rem !important;
    }
}

@media (max-width: 767.98px) {
    .sales-app-active .report-title {
        font-size: 1.5rem;
    }

    .agent-history-table-wrap {
        overflow: visible;
    }

    .agent-history-table,
    .agent-history-table tbody,
    .agent-history-table tr,
    .agent-history-table td {
        display: block;
        width: 100%;
    }

    .agent-history-table thead {
        display: none;
    }

    .agent-history-table tr {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        box-shadow: 0 10px 22px rgba(15, 23, 42, 0.05);
        margin: 0.75rem;
        padding: 0.75rem;
    }

    .agent-history-table td {
        border: 0 !important;
        display: grid;
        gap: 0.45rem;
        grid-template-columns: minmax(7.8rem, 42%) minmax(0, 1fr);
        overflow-wrap: anywhere;
        padding: 0.3rem 0 !important;
    }

    .agent-history-table td::before {
        color: #334155;
        font-weight: 800;
    }

    .agent-history-table .btn,
    .agent-history-table .form-control,
    .agent-history-table .form-select {
        border-radius: 12px;
        min-height: 42px;
    }

    .sales-bottom-tabs {
        border-radius: 20px 20px 0 0;
        max-width: none;
        padding: 0.48rem 0.46rem calc(0.55rem + env(safe-area-inset-bottom));
        width: 100%;
    }

    .sales-bottom-tab,
    .sales-bottom-tab:link,
    .sales-bottom-tab:visited {
        border-radius: 15px;
        min-height: 60px;
    }
}
