body:has(.tracking-dialog[open]) {
    overflow: hidden;
}

.tracking-dialog {
    position: fixed;
    inset: 0 0 0 auto;
    box-sizing: border-box;
    width: min(560px, 94vw);
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden !important;
    background: #fff;
    box-shadow: -16px 0 42px rgba(16, 24, 40, 0.22);
}

.tracking-dialog[open] {
    display: flex !important;
    flex-direction: column;
}

.tracking-dialog::backdrop {
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(1px);
}

.tracking-dialog .dialog-header,
.tracking-dialog .dialog-actions {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    width: 100%;
    padding: 18px 22px;
    background: #fff;
}

.tracking-dialog .dialog-header {
    border-bottom: 1px solid #e4e7ec;
}

.tracking-dialog .dialog-actions {
    border-top: 1px solid #e4e7ec;
}

/* app.css still contains the old centered modal two-column grid. The drawer
   must be a single vertical flow with its own scroll container. */
.tracking-dialog .tracking-dialog-body {
    position: relative;
    display: block !important;
    grid-template-columns: none !important;
    gap: 0 !important;
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    padding: 24px 22px 48px;
}

.tracking-dialog .tracking-dialog-body > * {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.tracking-dialog-body:focus {
    outline: none;
}

.tracking-section-title {
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e4e7ec;
    color: #667085;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tracking-dialog .timeline,
.tracking-dialog .tracking-history-timeline {
    display: block !important;
    width: 100%;
    max-width: 100%;
    margin: 0 0 28px;
}

.tracking-history-timeline {
    gap: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.tracking-history-timeline .timeline-item {
    position: relative;
    display: grid !important;
    grid-template-columns: 18px minmax(0, 1fr) !important;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    padding: 0 0 24px;
}

.tracking-history-timeline .timeline-item:last-child {
    padding-bottom: 0;
}

.tracking-history-timeline .timeline-item:not(:last-child)::before {
    content: '';
    position: absolute;
    top: 14px;
    bottom: -2px;
    left: 5px;
    width: 2px;
    background: #b7ded1;
}

.tracking-history-timeline .timeline-marker {
    position: relative;
    z-index: 1;
    width: 12px;
    height: 12px;
    margin-top: 3px;
    border-radius: 999px;
    background: #079455;
    box-shadow: none;
}

.tracking-event-content {
    min-width: 0;
    max-width: 100%;
}

.tracking-event-date {
    margin-bottom: 4px;
    color: #667085;
    font-size: 12px;
    line-height: 1.35;
}

.tracking-event-title {
    display: block;
    color: #101828;
    font-size: 14px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.tracking-event-location {
    margin-top: 4px;
    color: #667085;
    font-size: 12px;
}

.order-summary-title {
    margin-top: 4px;
}

.tracking-dialog .order-summary-list {
    display: grid;
    width: 100%;
    max-width: 100%;
    gap: 0;
    border: 1px solid #e4e7ec;
    border-radius: 10px;
    overflow: hidden;
}

.tracking-dialog .order-summary-list > div {
    display: grid;
    grid-template-columns: minmax(120px, 38%) minmax(0, 1fr);
    gap: 14px;
    width: 100%;
    padding: 11px 16px;
    border-bottom: 1px solid #eef1f4;
}

.tracking-dialog .order-summary-list > div:last-child {
    border-bottom: 0;
}

.tracking-dialog .order-summary-list span {
    color: #667085;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.tracking-dialog .order-summary-list strong {
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: right;
}

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

@media (max-width: 1180px) {
    .shopify-summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .tracking-dialog {
        width: 100vw;
    }

    .tracking-dialog .dialog-header,
    .tracking-dialog .dialog-actions,
    .tracking-dialog .tracking-dialog-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .tracking-dialog .order-summary-list > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .tracking-dialog .order-summary-list strong {
        text-align: left;
    }

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

/* Shopify workflow polish. */
.shopify-stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 84px;
}

.shopify-stat-card > div {
    display: grid;
    gap: 2px;
}

.shopify-stat-card strong {
    font-size: 22px;
    line-height: 1.1;
}

.shopify-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 7px;
}

.shopify-stat-icon .nav-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
}

.shopify-stat-icon.total { color: #175cd3; background: #eaf2ff; }
.shopify-stat-icon.booked { color: #087a55; background: #e7f6f0; }
.shopify-stat-icon.confirmed { color: #1570a6; background: #e7f4fa; }
.shopify-stat-icon.pending { color: #9a6700; background: #fff4d8; }
.shopify-stat-icon.hold { color: #6941c6; background: #f1edff; }
.shopify-stat-icon.cancelled { color: #b42318; background: #feeceb; }

.status-tab span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
}

.status-tab.active span {
    color: #087a55;
    background: #dff5eb;
}

.bulk-action-bar {
    position: fixed;
    z-index: 24;
    left: calc(228px + (100vw - 228px) / 2);
    bottom: 20px;
    width: max-content;
    max-width: calc(100vw - 260px);
    margin: 0;
    transform: translateX(-50%);
    animation: bulk-bar-in 180ms ease-out;
}

.tracking-orders-table.has-selection th:first-child,
.tracking-orders-table.has-selection td:first-child {
    width: 48px;
    min-width: 48px;
    text-align: center;
}

.tracking-orders-table input[type="checkbox"] {
    appearance: auto;
    display: inline-block;
    width: 18px;
    min-width: 18px;
    max-width: 18px;
    height: 18px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border-radius: 4px;
    box-shadow: none;
    vertical-align: middle;
    accent-color: var(--dream-red);
    cursor: pointer;
}

.tracking-orders-table input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.tracking-loadsheet-bar .btn.secondary {
    color: #fff;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.3);
}

.app-shell.sidebar-collapsed .bulk-action-bar {
    left: calc(68px + (100vw - 68px) / 2);
}

.optional-label {
    color: #667085;
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
}

.content > .panel,
.content > .table-panel,
.content > .grid,
.content > .dashboard-hero {
    animation: content-enter 220ms ease-out both;
}

.nav-link,
.stat-card,
.operation-card,
.status-tab {
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.stat-card:hover,
.operation-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .08);
}

@keyframes content-enter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bulk-bar-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 980px) {
    .bulk-action-bar,
    .app-shell.sidebar-collapsed .bulk-action-bar {
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        transform: none;
    }

    @keyframes bulk-bar-in {
        from { opacity: 0; transform: translateY(8px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

@media (prefers-reduced-motion: reduce) {
    .content > .panel,
    .content > .table-panel,
    .content > .grid,
    .content > .dashboard-hero,
    .bulk-action-bar {
        animation: none;
    }

    .nav-link,
    .stat-card,
    .operation-card,
    .status-tab {
        transition: none;
    }
}

/* Loadsheet history mirrors the courier-first operational hierarchy. */
.loadsheet-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 112px;
    padding: 24px 26px;
    color: #fff;
    border: 1px solid #2b2b2b;
    border-bottom: 3px solid var(--dream-red);
    border-radius: 7px;
    background:
        linear-gradient(90deg, rgba(217, 4, 22, .14), transparent 38%),
        #0d0d0e;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .12);
}

.loadsheet-hero-copy {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.loadsheet-hero h2,
.loadsheet-hero p {
    margin: 0;
}

.loadsheet-hero h2 {
    font-size: 24px;
    letter-spacing: 0;
}

.loadsheet-hero p {
    margin-top: 4px;
    color: #d0d5dd;
    line-height: 1.45;
}

.loadsheet-hero-mark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 8px 11px;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 6px;
    color: #e5e7eb;
    background: rgba(255, 255, 255, .06);
    font-size: 12px;
    font-weight: 700;
}

.loadsheet-hero-mark > span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34c38f;
    box-shadow: 0 0 0 3px rgba(52, 195, 143, .14);
}

.loadsheet-hero-icon,
.loadsheet-document-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 7px;
    color: #fff;
    background: rgba(255, 255, 255, .09);
}

.loadsheet-hero-icon .nav-icon,
.loadsheet-document-icon .nav-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    color: inherit;
    background: transparent;
}

.loadsheet-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.loadsheet-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 88px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .035);
}

.loadsheet-stat > span {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 7px;
    color: #175cd3;
    background: #eff6ff;
}

.loadsheet-stat:nth-child(2) > span {
    color: #12805c;
    background: #e7f6ef;
}

.loadsheet-stat:nth-child(3) > span {
    color: #a15c00;
    background: #fff6df;
}

.loadsheet-stat:nth-child(4) > span {
    color: #6941c6;
    background: #f4f0ff;
}

.loadsheet-stat .nav-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    color: inherit;
    background: transparent;
}

.loadsheet-stat div {
    display: grid;
    min-width: 0;
}

.loadsheet-stat strong {
    overflow-wrap: anywhere;
    font-size: 22px;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.loadsheet-stat small,
.loadsheet-row-total small {
    color: #667085;
    font-size: 11px;
    font-weight: 600;
    text-transform: none;
}

.loadsheet-history-panel {
    margin-top: 28px;
    background: transparent;
}

.loadsheet-search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(540px, 100%);
    min-height: 58px;
    margin-bottom: 28px;
    padding: 8px 8px 8px 16px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(15, 23, 42, .025);
}

.loadsheet-search > span {
    color: #667085;
}

.loadsheet-search > span .nav-icon {
    width: 20px;
    height: 20px;
    background: transparent;
}

.loadsheet-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    font-size: 14px;
}

.loadsheet-search input:focus {
    outline: 0;
    box-shadow: none;
}

.loadsheet-list {
    display: grid;
    gap: 14px;
}

.loadsheet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 92px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .025);
    transition: background-color 160ms ease, transform 160ms ease;
}

.loadsheet-row:hover {
    border-color: #d2d6dc;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
    transform: translateX(2px);
}

.loadsheet-row-main,
.loadsheet-row-actions,
.loadsheet-meta {
    display: flex;
    align-items: center;
}

.loadsheet-row-main {
    min-width: 0;
    gap: 12px;
}

.loadsheet-document-icon {
    color: var(--dream-red);
    background: var(--dream-red-soft);
}

.loadsheet-number {
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.loadsheet-number .badge {
    margin-left: 8px;
}

.loadsheet-meta {
    flex-wrap: wrap;
    gap: 7px 16px;
    margin-top: 5px;
    color: #667085;
    font-size: 12px;
}

.loadsheet-meta span:not(:last-child)::after {
    content: '';
    display: inline-block;
    width: 3px;
    height: 3px;
    margin-left: 16px;
    border-radius: 50%;
    vertical-align: middle;
    background: #c7cdd5;
}

.loadsheet-row-actions {
    flex: 0 0 auto;
    gap: 12px;
}

.loadsheet-row-total {
    display: grid;
    min-width: 64px;
    text-align: center;
}

.loadsheet-row-total strong {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.loadsheet-document-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-left: 2px;
}

.loadsheet-document-actions .btn.icon-only {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
}

.loadsheet-document-actions .nav-icon {
    width: 20px;
    height: 20px;
    margin: 0;
    color: inherit;
    background: transparent;
}

.loadsheet-history-panel > .pagination {
    margin-top: 8px;
    padding-inline: 0;
}

.booking-confirm-dialog {
    width: min(460px, calc(100vw - 24px));
}

.booking-confirm-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 22px;
}

.booking-confirm-body strong {
    font-size: 18px;
}

.booking-confirm-body p {
    margin: 7px 0 0;
    color: #667085;
    line-height: 1.5;
}

.booking-confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    color: var(--dream-red);
    background: var(--dream-red-soft);
    border-radius: 7px;
}

.booking-confirm-icon .nav-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
}

@media (max-width: 900px) {
    .loadsheet-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .loadsheet-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .loadsheet-row-actions {
        width: 100%;
        justify-content: flex-start;
    }

}

@media (max-width: 560px) {
    .loadsheet-hero {
        align-items: stretch;
        flex-direction: column;
        min-height: 0;
        padding: 18px;
    }

    .loadsheet-hero-mark {
        align-self: flex-start;
    }

    .loadsheet-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .loadsheet-stat {
        align-items: flex-start;
        flex-direction: column;
        min-height: 124px;
        padding: 14px;
    }

    .loadsheet-stat strong {
        font-size: 19px;
    }

    .loadsheet-list {
        gap: 10px;
    }

    .loadsheet-row {
        gap: 14px;
        padding: 16px;
    }

    .loadsheet-number {
        display: grid;
        gap: 7px;
    }

    .loadsheet-number .badge {
        width: fit-content;
        margin-left: 0;
    }

    .loadsheet-row-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
        align-items: center;
    }

    .loadsheet-row-total {
        text-align: left;
    }

    .loadsheet-document-actions {
        padding-left: 0;
    }

    .loadsheet-meta span:not(:last-child)::after {
        display: none;
    }
}

@media (max-width: 380px) {
    .loadsheet-stats {
        grid-template-columns: 1fr;
    }

    .loadsheet-stat {
        flex-direction: row;
        min-height: 82px;
    }
}
