body:not(.public-store-page) {
    overflow-x: hidden;
}

.app-navbar {
    min-height: 70px;
}

.app-navbar .container {
    gap: 12px;
}

.brand-mark {
    min-width: 190px;
    margin-right: .5rem;
}

.brand-mark img {
    width: 190px;
    height: 58px;
    max-width: 46vw;
}

.app-navbar .navbar-nav {
    gap: .35rem !important;
}

.app-navbar .navbar-nav .nav-link,
.app-navbar .navbar-nav .btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.app-navbar .dropdown-menu {
    min-width: 220px;
    padding: .4rem;
    border-color: #e4e7ec;
    box-shadow: 0 12px 30px rgba(16, 24, 40, .12);
}

.app-navbar .dropdown-item {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: .55rem;
    border-radius: 6px;
}

.admin-shell {
    width: min(100% - 32px, 1480px);
}

.dashboard-tools {
    position: relative;
}

.dashboard-tools > summary {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    list-style: none;
    cursor: pointer;
    border: 1px solid #d0d5dd;
    border-radius: 999px;
    padding: .55rem .9rem;
    color: #344054;
    font-weight: 700;
    background: #fff;
}

.dashboard-tools > summary::-webkit-details-marker {
    display: none;
}

.dashboard-tools[open] > summary {
    border-color: #98a2b3;
    background: #f9fafb;
}

.dashboard-tools-menu {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    right: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: min(480px, calc(100vw - 32px));
    padding: 12px;
    background: #fff;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    box-shadow: 0 16px 40px rgba(16, 24, 40, .16);
}

.dashboard-tools-menu .btn {
    justify-content: flex-start;
    text-align: left;
    white-space: normal;
}

.admin-shell .table-responsive {
    max-width: 100%;
    overscroll-behavior-inline: contain;
}

.admin-shell .btn,
.admin-header .btn {
    max-width: 100%;
}

.dashboard-report-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    list-style: none;
}

.dashboard-report-summary::-webkit-details-marker { display: none; }
.dashboard-report-summary > span:first-child { display: grid; gap: 3px; }
.dashboard-report-summary strong { color: #101828; }
.dashboard-report-summary > span:last-child { white-space: nowrap; }
.dashboard-report-card[open] .dashboard-report-summary { border-bottom: 1px solid #e4e7ec; }
.dashboard-report-summary .bi-chevron-down { margin-left: 6px; transition: transform .18s ease; }
.dashboard-report-card[open] .dashboard-report-summary .bi-chevron-down { transform: rotate(180deg); }

@media (max-width: 767.98px) {
    .btn:not(.btn-link):not(.btn-close):not(.navbar-toggler) {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .4rem;
        min-height: 42px;
        line-height: 1.2;
        text-align: center;
        vertical-align: middle;
        white-space: normal;
    }

    .btn:not(.btn-link):not(.btn-close):not(.navbar-toggler) > i,
    .btn:not(.btn-link):not(.btn-close):not(.navbar-toggler) > svg,
    .btn:not(.btn-link):not(.btn-close):not(.navbar-toggler) > img {
        flex: 0 0 auto;
        line-height: 1;
    }
}

@media (max-width: 1199.98px) {
    .brand-mark {
        min-width: 170px;
    }

    .brand-mark img {
        width: 170px;
        height: 54px;
    }
}

@media (max-width: 991.98px) {
    .app-navbar {
        min-height: 64px;
    }

    .app-navbar .navbar-collapse {
        max-height: calc(100dvh - 74px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .app-navbar .navbar-nav .nav-link,
    .app-navbar .navbar-nav .btn {
        width: 100%;
        justify-content: flex-start;
        min-height: 46px;
    }

    .app-navbar .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin-top: .3rem;
        box-shadow: none;
    }

    .dashboard-tools-menu {
        right: auto;
        left: 0;
    }
}

@media (max-width: 575.98px) {
    .dashboard-report-summary { align-items: flex-start; padding: 14px 16px; }
    .dashboard-report-content { padding: 16px !important; }
    .admin-shell {
        width: min(100% - 20px, 1480px);
        padding-top: 18px;
    }

    .dashboard-tools-menu {
        grid-template-columns: 1fr;
        width: min(320px, calc(100vw - 20px));
    }

    .admin-shell .table-responsive table {
        min-width: 680px;
    }

    .admin-header {
        gap: 12px;
    }

    .admin-header > div:last-child {
        display: flex;
        align-items: stretch;
        gap: 8px;
    }

    .admin-header > div:last-child > .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

/* Shared admin layout: keep module headers, controls and lists on one rhythm. */
:root {
    --app-border: #e4e7ec;
    --app-border-strong: #d0d5dd;
    --app-focus: rgba(34, 197, 94, .18);
}

.admin-shell {
    padding-top: clamp(20px, 3vw, 34px);
    padding-bottom: clamp(28px, 4vw, 48px);
}

.admin-shell .admin-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.admin-shell .admin-header > div:first-child {
    min-width: 0;
}

.admin-shell .admin-header h1 {
    margin-top: .7rem !important;
    margin-bottom: .35rem !important;
    font-size: clamp(1.55rem, 2.2vw, 2rem);
    line-height: 1.18;
    overflow-wrap: anywhere;
}

.admin-shell .admin-header p {
    max-width: 72ch;
    margin-bottom: 0;
    color: #667085;
    line-height: 1.5;
}

.admin-shell .admin-header > div:last-child {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.admin-shell .admin-header .btn,
.admin-shell .btn {
    min-height: 42px;
    max-width: 100%;
    align-items: center;
    justify-content: center;
    line-height: 1.25;
    white-space: normal;
}

.admin-shell .btn.btn-sm {
    min-height: 36px;
}

.admin-shell .btn i {
    flex: 0 0 auto;
    line-height: 1;
}

.admin-shell .form-control:not(.form-control-sm),
.admin-shell .form-select:not(.form-select-sm) {
    min-height: 44px;
    border-color: var(--app-border-strong);
    border-radius: 7px;
}

.admin-shell textarea.form-control:not(.form-control-sm) {
    min-height: 88px;
}

.admin-shell .form-control:focus,
.admin-shell .form-select:focus {
    border-color: #22a559;
    box-shadow: 0 0 0 .2rem var(--app-focus);
}

.admin-shell .card,
.admin-shell .card-soft,
.admin-shell .admin-panel,
.admin-shell .metric-card,
.admin-shell .stat-card {
    border-radius: 8px;
}

.admin-shell .table-responsive {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.admin-shell .table-responsive > .table {
    margin-bottom: 0;
    vertical-align: middle;
}

.admin-shell .table thead th {
    color: #344054;
    font-size: .82rem;
    font-weight: 750;
    white-space: nowrap;
}

.modal .modal-dialog {
    max-height: calc(100dvh - 24px);
}

.modal .modal-content {
    display: flex;
    max-height: calc(100dvh - 24px);
    overflow: hidden;
    border: 1px solid rgba(16, 24, 40, .08);
    border-radius: 8px;
}

.modal .modal-header,
.modal .modal-footer {
    flex: 0 0 auto;
    background: #fff;
}

.modal .modal-body {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    .admin-shell {
        width: min(100% - 20px, 1480px);
        padding-top: 18px;
    }

    .admin-shell .admin-header {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 18px;
    }

    .admin-shell .admin-header > div:last-child {
        justify-content: flex-start;
        width: 100%;
    }

    .admin-shell .admin-header > div:last-child > .btn {
        flex: 1 1 140px;
    }

    .admin-shell .metric-card,
    .admin-shell .stat-card {
        min-width: 0;
        height: 100%;
        overflow-wrap: anywhere;
    }

    .modal .modal-dialog {
        max-height: 100dvh;
        margin: 0;
    }

    .modal .modal-content {
        max-height: 100dvh;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 0;
    }

    .modal .modal-footer {
        gap: 8px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .modal .modal-footer .btn {
        min-height: 46px;
    }
}

@media (max-width: 767.98px) {
    .admin-shell .table-responsive[data-mobile-cards="true"] {
        width: 100%;
        overflow: visible !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        table-layout: fixed;
        border-collapse: separate !important;
        border-spacing: 0 10px !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > thead {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr {
        display: block !important;
        width: 100% !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr {
        margin: 0 0 10px;
        padding: 10px 12px;
        overflow: visible;
        background: #fff;
        border: 1px solid #e4e7ec;
        border-radius: 8px;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr:last-child {
        margin-bottom: 0;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td {
        display: grid !important;
        grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        width: 100% !important;
        min-width: 0 !important;
        padding: 8px 0 !important;
        color: inherit;
        text-align: left !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        border: 0 !important;
        border-bottom: 1px solid #eef1f4 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td::before {
        content: attr(data-label);
        color: #667085;
        font-size: .76rem;
        font-weight: 700;
        line-height: 1.4;
        text-align: left;
        text-transform: none;
        overflow-wrap: anywhere;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td:not([data-label])::before,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td[colspan]::before {
        content: none;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td[colspan] {
        display: block !important;
        text-align: center !important;
        border-bottom: 0 !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td:last-child {
        border-bottom: 0 !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] .btn,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] .dropdown,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] .dropdown-menu {
        max-width: 100%;
        white-space: normal;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] .btn-group,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] .dropdown {
        flex-wrap: wrap;
    }
}

@media (max-width: 767.98px) {
    html,
    body {
        max-width: 100%;
        overflow-x: clip !important;
    }

    .app-navbar .container {
        min-width: 0;
        max-width: 100%;
    }

    .app-navbar .brand-mark {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        max-width: calc(100% - 52px);
        margin-right: 0;
    }

    .app-navbar .brand-mark img {
        width: min(190px, 58vw) !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 52px;
    }

    .app-navbar .navbar-toggler {
        flex: 0 0 auto;
    }

    .admin-shell,
    .admin-shell .row,
    .admin-shell [class*="col-"],
    .admin-shell .card,
    .admin-shell .card-body,
    .admin-shell .d-flex,
    .admin-shell .d-grid,
    .admin-shell form {
        min-width: 0;
        max-width: 100%;
    }

    .admin-shell img,
    .admin-shell video,
    .admin-shell iframe {
        max-width: 100%;
    }

    .admin-shell .admin-header > div:last-child {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        width: 100%;
    }

    .admin-shell .admin-header > div:last-child > .btn {
        width: 100%;
        min-width: 0;
        white-space: nowrap;
    }

    .admin-shell .dashboard-tools {
        position: relative;
        width: 100%;
        min-width: 0;
    }

    .admin-shell .dashboard-tools > summary {
        justify-content: center;
        width: 100%;
        white-space: nowrap;
    }

    .admin-shell .dashboard-tools-menu {
        right: 0 !important;
        left: auto !important;
        width: min(420px, calc(100vw - 24px)) !important;
        max-width: calc(100vw - 24px);
        max-height: calc(100dvh - 100px);
        grid-template-columns: minmax(0, 1fr);
        box-sizing: border-box;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .admin-shell .dashboard-tools-menu > .btn {
        width: 100%;
        min-width: 0;
        white-space: normal;
        overflow-wrap: normal;
        word-break: keep-all;
    }

    .admin-shell .route-driver form {
        min-width: 0 !important;
        width: 100%;
        flex-wrap: wrap;
    }

    .admin-shell .table-responsive[data-mobile-cards="true"] {
        overflow: visible !important;
        border: 0 !important;
        border-radius: 0;
        background: transparent !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] {
        table-layout: auto;
        border-spacing: 0 !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody {
        display: grid !important;
        gap: 10px;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr {
        margin: 0 !important;
        padding: 10px 14px !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td {
        display: block !important;
        padding: 7px 0 !important;
        text-align: left !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td::before {
        display: block !important;
        margin: 0 0 3px;
        font-size: .68rem;
        font-weight: 700;
        line-height: 1.35;
        text-transform: uppercase;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] > tbody > tr > td[data-mobile-actions="true"] {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
        margin-top: 5px;
        padding-top: 11px !important;
        border-top: 1px solid #eef1f4 !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] > div,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] > form,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] > a,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] > button {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        gap: 7px;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] .btn {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        min-height: 42px;
        padding: .55rem .75rem;
        font-size: .9rem;
        white-space: normal !important;
        overflow-wrap: normal;
        word-break: keep-all;
        text-wrap: balance;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[colspan] {
        text-align: center !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[colspan]::before {
        display: none !important;
    }

    .modal.show:not(.barcode-scanner-modal) {
        position: fixed;
        inset: 0;
        width: auto;
        height: auto;
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
        overflow-x: hidden;
        overflow-y: auto;
    }

    .modal.show:not(.barcode-scanner-modal) > .modal-dialog {
        width: min(100%, 680px) !important;
        max-width: calc(100vw - 24px) !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: calc(100dvh - 24px) !important;
        margin: auto !important;
        align-self: center;
        transform: none !important;
    }

    .modal.show:not(.barcode-scanner-modal) > .modal-dialog > .modal-content {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        height: auto !important;
        min-height: 0 !important;
        max-height: calc(100dvh - 24px) !important;
        border: 1px solid var(--app-border) !important;
        border-radius: 10px !important;
        overflow: hidden;
    }

    .modal.show:not(.barcode-scanner-modal) .modal-header,
    .modal.show:not(.barcode-scanner-modal) .modal-footer {
        position: relative;
        z-index: 1;
        flex: 0 0 auto;
        background: #fff;
    }

    .modal.show:not(.barcode-scanner-modal) .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .modal.show:not(.barcode-scanner-modal) .modal-footer {
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
    }

    .modal.show:not(.barcode-scanner-modal) .modal-footer .btn {
        flex: 1 1 140px;
        width: auto;
        min-width: 0;
        min-height: 44px;
        white-space: normal !important;
        overflow-wrap: normal;
        word-break: keep-all;
        text-wrap: balance;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] .btn-group,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] .dropdown {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 7px;
        width: 100% !important;
        min-width: 0;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] .dropdown-menu {
        position: static !important;
        inset: auto !important;
        width: 100% !important;
        max-width: 100%;
        margin: 0 !important;
        transform: none !important;
    }

    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] .dropdown-toggle,
    .admin-shell .table-responsive > table[data-mobile-cards="true"] td[data-mobile-actions="true"] .btn-group > .btn {
        width: 100% !important;
        min-width: 0;
        white-space: normal !important;
        overflow-wrap: normal;
        word-break: keep-all;
        text-wrap: balance;
    }
}
