/**
 * Global mobile & small-screen responsiveness
 * Used by dashboard and public layouts
 */

/* ── Tighter spacing on small screens ── */
@media (max-width: 991.98px) {
    .row.g-4,
    .row.g-4 > * {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }

    .row.g-3,
    .row.g-3 > * {
        --bs-gutter-x: 0.625rem;
        --bs-gutter-y: 0.625rem;
    }

    .row.g-2,
    .row.g-2 > * {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }

    .mb-4 { margin-bottom: 0.875rem !important; }
    .mb-3 { margin-bottom: 0.625rem !important; }
    .gap-3 { gap: 0.5rem !important; }
    .gap-2 { gap: 0.3rem !important; }
    .gap-1 { gap: 0.2rem !important; }
}

@media (max-width: 575.98px) {
    .row.g-4,
    .row.g-4 > * {
        --bs-gutter-x: 0.4375rem;
        --bs-gutter-y: 0.4375rem;
    }

    .row.g-3,
    .row.g-3 > * {
        --bs-gutter-x: 0.3125rem;
        --bs-gutter-y: 0.3125rem;
    }

    .row.g-2,
    .row.g-2 > * {
        --bs-gutter-x: 0.3125rem;
        --bs-gutter-y: 0.3125rem;
    }

    .mb-4 { margin-bottom: 0.625rem !important; }
    .mb-3 { margin-bottom: 0.5rem !important; }
    .gap-3 { gap: 0.375rem !important; }
    .gap-2 { gap: 0.25rem !important; }
    .p-4 { padding: 0.75rem !important; }
    .p-3 { padding: 0.5rem !important; }
}

/**
 * Global mobile & small-screen responsiveness
 * Used by dashboard and public layouts
 */

/* ── Base mobile typography & compact controls ── */
@media (max-width: 767.98px) {
    body {
        font-size: 1rem;
        line-height: 1.55;
    }

    .btn {
        font-size: 0.9375rem;
        padding: 0.4rem 0.65rem;
        line-height: 1.35;
    }

    .btn-sm {
        font-size: 0.875rem;
        padding: 0.3rem 0.5rem;
    }

    .btn-lg {
        font-size: 1rem;
        padding: 0.5rem 0.8rem;
    }

    .form-control,
    .form-select {
        font-size: 1rem;
    }

    .badge {
        font-size: 0.8125rem;
        padding: 0.3em 0.5em;
    }

    .table .btn,
    .table .btn-sm {
        font-size: 0.8125rem;
        padding: 0.25rem 0.45rem;
        line-height: 1.25;
    }

    .card-footer .btn,
    .dashboard-card .btn:not(.btn-lg) {
        font-size: 0.875rem;
        padding: 0.35rem 0.55rem;
    }

    .small,
    small {
        font-size: 0.875rem !important;
    }
}

@media (max-width: 575.98px) {
    body {
        font-size: 0.9375rem;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.35rem 0.55rem;
    }

    .btn-sm {
        font-size: 0.8125rem;
        padding: 0.25rem 0.4rem;
    }

    .table .btn,
    .table .btn-sm {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }
}

/* ── Page header split layout (all screen sizes) ── */
.page-header.page-header-split {
    margin-bottom: 0.5rem;
    padding-bottom: 0.375rem;
}

.page-header.page-header-split .page-header-top {
    gap: 0.5rem;
}

.page-header.page-header-split h2 {
    line-height: 1.3;
    margin-bottom: 0;
}

.page-header.page-header-split .page-header-subtitle {
    margin-top: 0.25rem;
    line-height: 1.45;
}

.page-header.page-header-split + .dashboard-card,
.page-header.page-header-split + .alert + .dashboard-card,
.page-header.page-header-split + .row {
    margin-top: 0;
}

.page-header-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
    max-width: 58%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.page-header-actions::-webkit-scrollbar {
    display: none;
}

.page-header-actions .btn,
.page-header-action-btn,
.page-header-back-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.page-header-actions-secondary {
    margin-top: 0.5rem;
    max-width: 100%;
    width: 100%;
    justify-content: flex-start;
    padding-bottom: 0.125rem;
}

/* ── Page headers: mobile layout ── */
@media (max-width: 767.98px) {
    .page-header:not(.page-header-split) {
        margin-bottom: 0.75rem !important;
        padding-bottom: 0.5rem !important;
    }

    .page-header h2 {
        font-size: 1.35rem !important;
    }

    .page-header p,
    .page-header-subtitle {
        font-size: 0.875rem !important;
    }

    .page-header .d-flex.justify-content-between:not(.page-header-top),
    .page-header > .d-flex:not(.page-header-top) {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .page-header.page-header-split .page-header-top {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.4375rem;
    }

    .page-header.page-header-split h2 {
        font-size: 1.25rem !important;
        flex: 1 1 auto;
        min-width: 0;
    }

    .page-header.page-header-split {
        margin-bottom: 0.375rem !important;
        padding-bottom: 0.25rem !important;
    }

    .page-header.page-header-split .page-header-subtitle {
        font-size: 0.9rem !important;
        margin-top: 0.2rem;
    }

    .page-header-actions {
        max-width: 52%;
    }

    .page-header-actions .btn,
    .page-header-action-btn,
    .page-header-back-btn {
        font-size: 0.8125rem !important;
        padding: 0.32rem 0.55rem !important;
        width: auto !important;
        min-height: 0 !important;
    }

    .page-header-actions .btn i,
    .page-header-action-btn i,
    .page-header-back-btn i {
        font-size: 0.875rem;
    }

    .page-header-actions-secondary {
        max-width: 100%;
    }

    .page-header-actions-secondary {
        margin-top: 0.375rem;
        gap: 0.25rem;
    }

    .page-header-actions-secondary .btn {
        font-size: 0.8125rem !important;
        padding: 0.32rem 0.55rem !important;
        width: auto !important;
    }

    .page-header .btn:not(.page-header-action-btn):not(.page-header-back-btn),
    .page-header form .btn {
        width: 100%;
    }

    .page-header.page-header-split .page-header-actions .btn,
    .page-header.page-header-split .page-header-action-btn,
    .page-header.page-header-split .page-header-back-btn {
        width: auto !important;
    }

    .page-header .d-flex.gap-2:not(.page-header-actions) {
        flex-direction: column;
    }

    .page-header .d-flex.gap-2:not(.page-header-actions) .btn {
        width: 100%;
    }

    .page-header .invoice-action-btns {
        width: auto;
        max-width: none;
    }

    .page-header .invoice-action-btns .btn {
        width: auto;
        flex: 0 0 auto;
    }
}

@media (max-width: 575.98px) {
    .page-header.page-header-split h2,
    .page-header h2 {
        font-size: 1.1875rem !important;
    }

    .page-header.page-header-split .page-header-subtitle,
    .page-header-subtitle {
        font-size: 0.84375rem !important;
    }

    .page-header-actions {
        max-width: 48%;
        gap: 0.2rem;
    }

    .page-header-actions .btn,
    .page-header-action-btn,
    .page-header-back-btn {
        font-size: 0.75rem !important;
        padding: 0.28rem 0.45rem !important;
    }

    .page-header-actions .btn i,
    .page-header-action-btn i,
    .page-header-back-btn i {
        font-size: 0.8125rem;
    }
}

/* ── Dashboard cards: less padding ── */
@media (max-width: 767.98px) {
    .dashboard-card {
        padding: 0.875rem !important;
        margin-bottom: 0.75rem !important;
        border-radius: 10px;
    }

    .dashboard-card .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.4375rem;
        margin-bottom: 0.625rem !important;
        padding-bottom: 0.5rem !important;
    }

    .dashboard-card .card-title {
        font-size: 1rem !important;
    }

    .dashboard-card .card-header .d-flex,
    .dashboard-card .card-header form {
        width: 100%;
    }

    .dashboard-card .card-footer {
        margin: 0 -0.875rem -0.875rem !important;
        padding: 0.625rem 0.875rem !important;
        flex-direction: column;
        gap: 0.375rem;
        align-items: stretch !important;
    }

    .table {
        font-size: 0.875rem !important;
    }

    .dashboard-card .card-footer .btn {
        width: 100%;
    }

    .dashboard-summary-box {
        padding: 0.875rem !important;
    }

    .dashboard-summary-value {
        font-size: 1.3125rem !important;
    }
}

@media (max-width: 575.98px) {
    .dashboard-card {
        padding: 0.75rem !important;
    }

    .dashboard-card .card-footer {
        margin: 0 -0.75rem -0.75rem !important;
        padding: 0.625rem 0.75rem !important;
    }
}

/* ── Stat cards ── */
@media (max-width: 767.98px) {
    .stat-card {
        padding: 0.75rem 0.625rem !important;
    }

    .stat-card .stat-icon {
        width: 34px !important;
        height: 34px !important;
        font-size: 0.875rem !important;
        margin-bottom: 0.375rem !important;
    }

    .stat-card .stat-value {
        font-size: 1.4rem !important;
    }

    .stat-card .stat-label {
        font-size: 0.875rem !important;
    }

    .stat-card .stat-change {
        margin-top: 0.2rem !important;
        font-size: 0.75rem !important;
    }
}

/* ── Dashboard filter forms ── */
.dashboard-filter-form--inline {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: flex-start;
    width: 100%;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem 0.625rem;
}

.dashboard-filter-form--inline .dashboard-filter-fields {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 0.375rem;
    min-width: 0;
}

.dashboard-filter-form--inline .dashboard-filter-field {
    flex: 0 0 auto;
    min-width: 7.5rem;
}

.dashboard-filter-form--inline .dashboard-filter-field--narrow {
    min-width: 6.5rem;
    max-width: 9rem;
}

.dashboard-filter-form--inline .dashboard-filter-field--date {
    min-width: 8.75rem;
    max-width: 11rem;
}

.dashboard-filter-form--inline .dashboard-filter-field--grow {
    flex: 0 1 13rem;
    width: 13rem;
    min-width: 8rem;
    max-width: 16rem;
}

.dashboard-filter-form--inline .dashboard-filter-actions {
    flex: 0 0 auto;
    margin-top: 0;
    margin-left: 0;
    padding: 0;
    border-top: none;
    width: auto;
    gap: 0.375rem;
    justify-content: flex-start;
}

.dashboard-filter-form--inline .dashboard-filter-actions .btn {
    flex: 0 0 auto;
}

.dashboard-card:has(> .dashboard-filter-form) > .card-header {
    padding: 0.375rem 0.625rem;
}

.dashboard-card:has(> .dashboard-filter-form) > .card-header .card-title {
    font-size: 0.9375rem;
    font-weight: 600;
}

.dashboard-card:has(> .dashboard-filter-form) > .card-header .card-title .bi {
    font-size: 0.875rem;
}

.dashboard-filter-form {
    padding: 0.5rem 0.625rem 0.625rem;
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
}

.dashboard-filter-label,
.dashboard-filter-form .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #6e6e80;
    margin-bottom: 0.2rem;
    line-height: 1.25;
}

.dashboard-filter-form .form-control,
.dashboard-filter-form .form-select {
    min-height: 2.375rem;
    font-size: 0.9375rem;
    padding: 0.375rem 0.5rem;
}

.dashboard-filter-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.375rem;
    align-items: flex-end;
    width: auto;
    margin-top: 0.625rem;
}

.dashboard-filter-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    font-size: 0.875rem;
    padding: 0.45rem 0.65rem;
    line-height: 1.3;
    min-height: 2.375rem;
}

.dashboard-filter-actions--end {
    justify-content: flex-end;
}

.dashboard-filter-actions--end .btn {
    flex: 0 0 auto;
}

.dashboard-filter-meta,
.dashboard-filter-toolbar {
    border-top: 1px solid #ececf1;
    padding-top: 0.5rem;
    margin-top: 0.125rem;
}

@media (min-width: 992px) {
    .dashboard-filter-meta,
    .dashboard-filter-toolbar {
        border-top: none;
        padding-top: 0;
        margin-top: 0;
    }
}

@media (max-width: 767.98px) {
    .dashboard-card:has(> .dashboard-filter-form) > .card-header {
        padding: 0.3rem 0.5rem;
    }

    .dashboard-filter-form {
        padding: 0.4rem 0.5rem 0.5rem;
        --bs-gutter-x: 0.375rem;
        --bs-gutter-y: 0.375rem;
    }

    .dashboard-filter-form .form-control,
    .dashboard-filter-form .form-select {
        min-height: 2.5rem;
        font-size: 1rem;
        padding: 0.375rem 0.5rem;
    }

    .dashboard-filter-label,
    .dashboard-filter-form .form-label {
        font-size: 0.75rem;
        margin-bottom: 0.15rem;
    }

    .dashboard-filter-form:not(.dashboard-filter-form--inline) .dashboard-filter-actions {
        margin-top: 0.5rem;
        padding-top: 0.25rem;
        gap: 0.4375rem;
        border-top: 1px solid #ececf1;
    }

    .dashboard-filter-actions .btn {
        font-size: 0.9375rem;
        padding: 0.45rem 0.65rem;
        min-height: 2.375rem;
    }

    .dashboard-filter-form:not(.dashboard-filter-form--inline) > [class*="col-"]:not(.dashboard-filter-actions) {
        margin-bottom: 0.125rem;
    }

    .dashboard-filter-form--inline {
        flex-wrap: wrap;
        padding-bottom: 0.25rem;
    }

    .dashboard-filter-form--inline .dashboard-filter-fields {
        flex: 0 1 auto;
        justify-content: flex-start;
    }

    .dashboard-filter-form--inline .dashboard-filter-field {
        min-width: 6.5rem;
    }

    .dashboard-filter-form--inline.dashboard-filter-form--wrap-sm .dashboard-filter-fields {
        flex: 0 1 auto;
        min-width: 0;
    }

    .dashboard-filter-form--inline.dashboard-filter-form--wrap-sm .dashboard-filter-field {
        flex: 1 1 calc(50% - 0.1875rem);
        min-width: 0;
        max-width: none;
    }

    .dashboard-filter-form--inline.dashboard-filter-form--wrap-sm .dashboard-filter-actions {
        flex: 0 0 auto;
        width: auto;
        margin-left: 0;
        justify-content: flex-start;
        border-top: none;
        padding-top: 0;
        margin-top: 0;
        gap: 0.375rem;
    }

    .dashboard-filter-form--inline.dashboard-filter-form--wrap-sm .dashboard-filter-actions .btn {
        flex: 0 0 auto;
    }
}

/* ── Dashboard cards & stats: clearer small-screen layout ── */
@media (max-width: 767.98px) {
    .dashboard-card.mb-4,
    .dashboard-card.mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .dashboard-card > .card-header {
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .stat-card {
        padding: 0.625rem 0.5rem;
    }
}

@media (max-width: 575.98px) {
    .dashboard-filter-actions .btn {
        font-size: 0.875rem;
        padding: 0.4rem 0.55rem;
        min-height: 2.25rem;
    }

    .dashboard-filter-form {
        --bs-gutter-x: 0.375rem;
        --bs-gutter-y: 0.375rem;
    }
}

/* ── Filter / search forms (legacy) ── */
@media (max-width: 767.98px) {
    .dashboard-card form.row:not(.dashboard-filter-form),
    form.row.g-3:not(.dashboard-filter-form) {
        --bs-gutter-y: 0.5rem;
    }

    .dashboard-card form:not(.dashboard-filter-form) .col-md-3,
    .dashboard-card form:not(.dashboard-filter-form) .col-md-4,
    .dashboard-card form:not(.dashboard-filter-form) .col-md-6,
    .dashboard-card form:not(.dashboard-filter-form) .col-md-auto,
    form.row:not(.dashboard-filter-form) .col-md-3,
    form.row:not(.dashboard-filter-form) .col-md-4,
    form.row:not(.dashboard-filter-form) .col-md-6 {
        margin-bottom: 0.25rem;
    }

    .dashboard-card form .d-flex.gap-2:not(.dashboard-filter-actions),
    form .d-flex.gap-2.align-items-end:not(.dashboard-filter-actions) {
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
    }

    .dashboard-card form .d-flex.gap-2:not(.dashboard-filter-actions) .btn,
    form .d-flex.gap-2:not(.dashboard-filter-actions) .btn {
        width: 100%;
    }
}

/* Phone input: country code + national number */
.phone-input-group .phone-country-picker {
    position: relative;
    flex: 0 0 auto;
}

.phone-input-group .phone-country-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 6.75rem;
    max-width: 9.5rem;
    padding-right: 1.75rem;
    white-space: nowrap;
    text-align: left;
    background-image: none;
}

.phone-input-group .phone-country-flag {
    font-size: 1.1em;
    line-height: 1;
}

.phone-input-group .phone-country-dial {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.phone-input-group .phone-country-chevron {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 0.75rem;
    opacity: 0.65;
}

.phone-input-group .phone-country-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    z-index: 1080;
    min-width: 16.5rem;
    max-width: min(22rem, calc(100vw - 2rem));
    max-height: 14rem;
    overflow-y: auto;
    padding: 0.35rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
    background: var(--bs-body-bg, #fff);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.12);
}

.phone-input-group .phone-country-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 0;
    border-radius: 0.3rem;
    background: transparent;
    color: inherit;
    text-align: left;
}

.phone-input-group .phone-country-option:hover,
.phone-input-group .phone-country-option:focus-visible {
    background: rgba(25, 135, 84, 0.08);
    outline: none;
}

.phone-input-group .phone-country-option.is-active {
    background: rgba(25, 135, 84, 0.14);
    font-weight: 600;
}

.phone-input-group .phone-country-option .phone-country-name {
    flex: 1 1 auto;
    min-width: 0;
}

.phone-input-group .phone-country-option .phone-country-code {
    flex: 0 0 auto;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.875em;
    white-space: nowrap;
}

.phone-input-group .form-control[type="tel"] {
    min-width: 0;
}

@media (max-width: 575.98px) {
    .phone-input-group {
        flex-wrap: nowrap;
    }

    .phone-input-group .phone-country-trigger {
        max-width: 42%;
        min-width: 6.5rem;
        font-size: 0.8125rem;
        padding-left: 0.45rem;
        padding-right: 1.5rem;
    }

    .phone-input-group .phone-country-menu {
        min-width: 14.5rem;
    }
}

/* Compact tables: no forced horizontal scroll on large screens */
.table-responsive-fit {
    overflow-x: visible;
}

.table-responsive-fit table {
    width: 100%;
    min-width: 0;
}

.table-responsive-fit table.pending-users-table,
.table-responsive-fit table.order-detail-meta-table,
.table-responsive-fit table.order-detail-items-table {
    table-layout: fixed;
}

.table-responsive-fit table.order-detail-meta-table td:first-child {
    width: 11.25rem;
    white-space: nowrap;
}

.table-responsive-fit table.order-detail-meta-table td:last-child {
    word-break: break-word;
}

.table-responsive-fit table.order-detail-items-table th:nth-child(1),
.table-responsive-fit table.order-detail-items-table td:nth-child(1) {
    width: 38%;
}

.table-responsive-fit table.order-detail-items-table th:nth-child(2),
.table-responsive-fit table.order-detail-items-table td:nth-child(2) {
    width: 12%;
}

.table-responsive-fit table.order-detail-items-table th:nth-child(3),
.table-responsive-fit table.order-detail-items-table td:nth-child(3) {
    width: 25%;
}

.table-responsive-fit table.order-detail-items-table th:nth-child(4),
.table-responsive-fit table.order-detail-items-table td:nth-child(4) {
    width: 25%;
}

.table-responsive-fit table.pending-users-table {
    width: 100%;
    min-width: 0;
}

.table-responsive-fit table.pending-users-table th:nth-child(1),
.table-responsive-fit table.pending-users-table td:nth-child(1) {
    width: 34%;
}

.table-responsive-fit table.pending-users-table th:nth-child(2),
.table-responsive-fit table.pending-users-table td:nth-child(2) {
    width: 41%;
}

.table-responsive-fit table.pending-users-table th:nth-child(3),
.table-responsive-fit table.pending-users-table td:nth-child(3) {
    width: 25%;
}

@media (min-width: 992px) {
    .table-responsive-fit {
        overflow-x: visible !important;
    }

    .dashboard-card .table-responsive-fit .table-scroll-hint,
    .dashboard-card .table-scroll-pro:has(.table-responsive-fit) .table-scroll-hint {
        display: none !important;
    }
}

@media (max-width: 767.98px) {
    .table-responsive-fit {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive-fit table.pending-users-table,
    .table-responsive-fit table.order-detail-meta-table,
    .table-responsive-fit table.order-detail-items-table {
        table-layout: auto;
    }

    .table-responsive-fit table.order-detail-items-table {
        min-width: 34rem;
    }

    .table-responsive-fit table.pending-users-table {
        min-width: 0;
    }
}

/* ── Professional horizontal-scroll tables ── */
.table-scroll-pro {
    position: relative;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.table-scroll-pro .table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    margin: 0;
    padding: 0;
}

.table-scroll-pro .table-responsive:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.table-scroll-pro table.table-pro {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table-scroll-pro table.table-pro thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f3f4f6;
    white-space: nowrap;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #5c5c6f;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #e5e7eb;
    vertical-align: middle;
}

.table-scroll-pro table.table-pro tbody td {
    padding: 0.8125rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f1f3;
    font-size: 0.8125rem;
    color: #1a1a1a;
    background: #fff;
}

.table-scroll-pro table.table-pro tbody tr:last-child td {
    border-bottom: none;
}

.table-scroll-pro table.table-pro tbody tr:hover td {
    background: #f8fafc;
}

.table-scroll-pro table.table-pro.table-striped tbody tr:nth-of-type(even) td {
    background: #fafbfc;
}

.table-scroll-pro table.table-pro.table-striped tbody tr:nth-of-type(even):hover td {
    background: #f3f6f9;
}

/* First column sticky for wide tables */
.table-scroll-pro.is-scrollable-x table.table-pro thead th:first-child,
.table-scroll-pro.is-scrollable-x table.table-pro tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.04);
}

.table-scroll-pro.is-scrollable-x table.table-pro thead th:first-child {
    z-index: 3;
    background: #f3f4f6;
}

.table-scroll-pro.is-scrollable-x table.table-pro tbody td:first-child {
    background: #fff;
}

.table-scroll-pro.is-scrollable-x table.table-pro.table-striped tbody tr:nth-of-type(even) td:first-child {
    background: #fafbfc;
}

[dir="rtl"] .table-scroll-pro.is-scrollable-x table.table-pro thead th:first-child,
[dir="rtl"] .table-scroll-pro.is-scrollable-x table.table-pro tbody td:first-child {
    left: auto;
    right: 0;
    box-shadow: -2px 0 6px rgba(0, 0, 0, 0.04);
}

/* Scroll fade edges */
.table-scroll-pro::before,
.table-scroll-pro::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 32px;
    pointer-events: none;
    z-index: 4;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.table-scroll-pro::before {
    left: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.98) 15%, rgba(255, 255, 255, 0));
}

.table-scroll-pro::after {
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.98) 15%, rgba(255, 255, 255, 0));
}

.table-scroll-pro.can-scroll-left::before {
    opacity: 1;
}

.table-scroll-pro.can-scroll-right::after {
    opacity: 1;
}

/* Scroll hint */
.table-scroll-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: #6e6e80;
    background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
    border-top: 1px solid #e5e7eb;
}

.table-scroll-hint i {
    font-size: 0.75rem;
    opacity: 0.85;
}

/* Scroll arrow buttons */
.table-scroll-controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.table-scroll-btn {
    pointer-events: auto;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.96);
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.table-scroll-pro.is-scrollable-x .table-scroll-btn {
    opacity: 1;
}

.table-scroll-btn:hover {
    background: #fff;
    color: #007bff;
    transform: translateY(-50%) scale(1.05);
}

.table-scroll-btn--left {
    left: 0.375rem;
}

.table-scroll-btn--right {
    right: 0.375rem;
}

.table-scroll-pro:not(.can-scroll-left) .table-scroll-btn--left,
.table-scroll-pro:not(.can-scroll-right) .table-scroll-btn--right {
    opacity: 0;
    pointer-events: none;
}

/* Custom scrollbar */
.table-scroll-pro .table-responsive::-webkit-scrollbar {
    height: 7px;
}

.table-scroll-pro .table-responsive::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 999px;
}

.table-scroll-pro .table-responsive::-webkit-scrollbar-thumb {
    background: #c5cad1;
    border-radius: 999px;
}

.table-scroll-pro .table-responsive::-webkit-scrollbar-thumb:hover {
    background: #9aa3ad;
}

.table-scroll-pro .table-responsive {
    scrollbar-width: thin;
    scrollbar-color: #c5cad1 #f1f3f5;
}

/* Inside dashboard cards: edge-to-edge on small screens */
@media (max-width: 767.98px) {
    .dashboard-card .table-scroll-pro {
        margin-left: -0.875rem;
        margin-right: -0.875rem;
        width: calc(100% + 1.75rem);
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    .dashboard-card .card-header + .table-scroll-pro {
        margin-top: -0.25rem;
    }

    .table-scroll-pro table.table-pro thead th,
    .table-scroll-pro table.table-pro tbody td {
        padding: 0.625rem 0.75rem;
    }
}

/* Dashboard card with nested table-responsive (no wrapper yet) */
.dashboard-card .card-body.p-0 .table-scroll-pro,
.dashboard-card .table-responsive {
    border-radius: 0 0 10px 10px;
}

@media (max-width: 575.98px) {
    .dashboard-card .table-scroll-pro {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        width: calc(100% + 1.5rem);
    }

    .table-scroll-btn {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }
}

/* ── Invoice action buttons (view / print / download) ── */
.invoice-action-btns {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.invoice-action-btns::-webkit-scrollbar {
    display: none;
}

.invoice-action-btns .btn,
.invoice-table-actions .btn {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.32rem 0.55rem;
    line-height: 1.25;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.invoice-action-btns .btn i,
.invoice-table-actions .btn i {
    font-size: 0.8125rem;
    line-height: 1;
}

.invoice-table-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .invoice-action-btns {
        gap: 0.25rem;
    }

    .invoice-action-btns .btn,
    .invoice-table-actions .btn {
        font-size: 0.6875rem;
        padding: 0.25rem 0.45rem;
    }

    .invoice-action-btns .btn i,
    .invoice-table-actions .btn i {
        font-size: 0.8125rem;
    }
}

@media (max-width: 575.98px) {
    .invoice-action-btns .btn,
    .invoice-table-actions .btn {
        font-size: 0.65625rem;
        padding: 0.22rem 0.4rem;
    }
}

/* Invoice card header: keep action row horizontal */
.invoice-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.invoice-card-header .card-title {
    flex: 0 1 auto;
    min-width: 0;
}

.invoice-card-header .invoice-action-btns {
    flex: 1 1 auto;
    justify-content: flex-end;
    min-width: 0;
}

@media (max-width: 575.98px) {
    .invoice-card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-card-header .invoice-action-btns {
        justify-content: flex-start;
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-body .row.g-3 {
        --bs-gutter-y: 0.5rem;
    }
}

/* ── Nav pills / tabs ── */
@media (max-width: 767.98px) {
    .nav-pills {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.2rem;
        gap: 0.25rem !important;
    }

    .nav-pills .nav-link {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.875rem !important;
        padding: 0.35rem 0.6rem !important;
    }
}

/* ── Top navbar (dashboard) ── */
@media (max-width: 767.98px) {
    .top-navbar {
        padding: 0.625rem 0.75rem !important;
        gap: 0.5rem;
    }

    .top-navbar .user-menu {
        gap: 0.375rem !important;
    }

    .top-navbar .navbar-brand .dashboard-title {
        font-size: 0.875rem !important;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-avatar {
        width: 34px !important;
        height: 34px !important;
        font-size: 0.75rem !important;
    }

    .user-avatar img {
        width: 34px !important;
        height: 34px !important;
    }
}

/* ── Dashboard sidebar overlay (no content push) ── */
@media (max-width: 992px) {
    .sidebar {
        margin-left: 0 !important;
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    }

    body.sidebar-open .main-content {
        margin-left: 0 !important;
    }

    .sidebar-overlay.active {
        display: block !important;
        background: rgba(0, 0, 0, 0.45);
    }
}

/* ── Public site: container padding ── */
@media (max-width: 767.98px) {
    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    main.page-shell {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .hero-section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .card-body {
        padding: 0.875rem;
    }

    .modal-body .table-responsive {
        margin: 0;
    }
}

@media (max-width: 575.98px) {
    .container,
    .container-fluid {
        padding-left: 0.625rem;
        padding-right: 0.625rem;
    }

    .top-navbar {
        padding: 0.5rem 0.625rem !important;
        gap: 0.375rem;
    }

    .top-navbar .navbar-brand .dashboard-title {
        font-size: 0.8125rem !important;
        max-width: 120px;
    }

    .user-avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.6875rem !important;
    }

    .user-avatar img {
        width: 30px !important;
        height: 30px !important;
    }

    .stat-card .stat-value {
        font-size: 1.25rem !important;
    }

    .stat-card .stat-icon {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.9375rem !important;
    }

    .dashboard-card .card-title {
        font-size: 0.9375rem !important;
    }

    .nav-pills .nav-link {
        font-size: 0.8125rem !important;
        padding: 0.3rem 0.5rem !important;
    }
}

/* ── Quick action buttons on admin dashboard ── */
@media (max-width: 767.98px) {
    .dashboard-card .row.g-3 .btn[style*="height: 60px"],
    .dashboard-card .row.g-3 a.btn {
        height: auto !important;
        min-height: 44px;
        padding: 0.5rem 0.625rem !important;
        font-size: 0.75rem !important;
    }
}

/* ── Pagination ── */
@media (max-width: 575.98px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }
}

/* ── Alerts & status banners ── */
@media (max-width: 575.98px) {
    .alert {
        padding: 0.625rem 0.75rem;
        font-size: 0.9375rem;
    }
}

/* ── Pre / log viewers ── */
@media (max-width: 767.98px) {
    pre {
        font-size: 0.6875rem !important;
        padding: 0.625rem !important;
    }
}

/* ── Order / invoice line-item tables: tight column spacing on small screens ── */
@media (max-width: 767.98px) {
    .table.order-line-table,
    table.order-line-table {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse;
        margin-bottom: 0 !important;
    }

    .order-line-table col.order-line-col-item {
        width: 54% !important;
    }

    .order-line-table col.order-line-col-qty {
        width: 8% !important;
    }

    .order-line-table col.order-line-col-amount {
        width: 38% !important;
    }

    .order-line-table thead th,
    .order-line-table tbody td,
    .order-line-table tfoot td {
        padding: 0.2rem 0.1rem !important;
        font-size: 0.875rem !important;
        line-height: 1.25 !important;
        vertical-align: middle !important;
        white-space: normal !important;
        border-spacing: 0;
    }

    .order-line-table thead th:nth-child(1),
    .order-line-table tbody td:nth-child(1),
    .order-line-table tfoot td[colspan] {
        padding-left: 0 !important;
        padding-right: 0.1rem !important;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .order-line-table thead th:nth-child(2),
    .order-line-table tbody td:nth-child(2) {
        width: 1.35rem !important;
        max-width: 1.35rem !important;
        padding-left: 0.04rem !important;
        padding-right: 0.04rem !important;
        text-align: right !important;
    }

    .order-line-table thead th:nth-child(3),
    .order-line-table tbody td:nth-child(3),
    .order-line-table tfoot td:last-child {
        width: 5.75rem !important;
        max-width: 5.75rem !important;
        padding-left: 0.06rem !important;
        padding-right: 0 !important;
        text-align: right !important;
        white-space: nowrap !important;
    }

    .order-line-table thead th {
        font-size: 0.75rem !important;
        padding-top: 0.12rem !important;
        padding-bottom: 0.12rem !important;
        letter-spacing: 0.02em;
    }

    .order-line-table tfoot td {
        padding-top: 0.14rem !important;
        padding-bottom: 0.14rem !important;
    }

    .order-line-table .fw-semibold,
    .order-line-table .fw-bold {
        font-weight: 600 !important;
    }

    .order-line-table tfoot .h5 {
        font-size: 0.9375rem !important;
        margin-bottom: 0 !important;
    }

    .table-responsive:has(.order-line-table),
    .dashboard-card .card-body > .table-responsive:has(.order-line-table),
    .dashboard-card .table-responsive:has(.order-line-table) {
        margin-left: 0 !important;
        margin-right: 0 !important;
        overflow-x: visible !important;
        -webkit-overflow-scrolling: auto;
    }
}

@media (max-width: 575.98px) {
    .order-line-table col.order-line-col-qty {
        width: 7% !important;
    }

    .order-line-table col.order-line-col-amount {
        width: 40% !important;
    }

    .order-line-table thead th:nth-child(2),
    .order-line-table tbody td:nth-child(2) {
        width: 1.2rem !important;
        max-width: 1.2rem !important;
        padding-left: 0.02rem !important;
        padding-right: 0.02rem !important;
    }

    .order-line-table thead th:nth-child(3),
    .order-line-table tbody td:nth-child(3),
    .order-line-table tfoot td:last-child {
        width: 5.25rem !important;
        max-width: 5.25rem !important;
    }

    .order-line-table thead th,
    .order-line-table tbody td,
    .order-line-table tfoot td {
        font-size: 0.8125rem !important;
        padding-top: 0.14rem !important;
        padding-bottom: 0.14rem !important;
    }
}

/* ── Order / invoice / cart line-item tables & totals ── */
@media (max-width: 767.98px) {
    .dashboard-card:has(> .card-header + .card-body) {
        padding: 0.625rem 0.625rem 0.5rem !important;
    }

    .dashboard-card:has(> .card-header + .card-body) > .card-header {
        margin-bottom: 0.375rem !important;
        padding-bottom: 0.375rem !important;
    }

    .dashboard-card .card-body {
        padding: 0.375rem 0 0 !important;
    }

    .dashboard-card .card-body > .table-responsive {
        margin-left: -0.125rem;
        margin-right: -0.125rem;
    }

    .dashboard-card .card-body .table,
    .dashboard-card .card-body table.table-pro {
        margin-bottom: 0;
    }

    .dashboard-card .card-body .table:not(.order-line-table) th,
    .dashboard-card .card-body .table:not(.order-line-table) td,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) thead th,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) tbody td,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) tfoot td {
        padding: 0.3rem 0.35rem !important;
        font-size: 0.875rem !important;
        line-height: 1.35;
    }

    .dashboard-card .card-body .order-line-table th,
    .dashboard-card .card-body .order-line-table td {
        font-size: 0.875rem !important;
        line-height: 1.35;
    }

    .dashboard-card .card-body .table:not(.order-line-table) thead th,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) thead th {
        font-size: 0.75rem !important;
        padding-top: 0.2rem !important;
        padding-bottom: 0.2rem !important;
        letter-spacing: 0.03em;
    }

    .dashboard-card .card-body .table:not(.order-line-table) tfoot td,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) tfoot td {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }

    .dashboard-card .card-body .table:not(.order-line-table) tfoot tr.border-top td {
        padding-top: 0.35rem !important;
    }

    .dashboard-card .card-body .order-line-table tfoot td {
        padding-top: 0.2rem !important;
        padding-bottom: 0.2rem !important;
    }

    .dashboard-card .card-body .table tfoot .h5,
    .dashboard-card .card-body .table tfoot .h4 {
        font-size: 1rem !important;
        margin-bottom: 0 !important;
    }

    .dashboard-card .card-body .table .fw-semibold {
        font-size: 0.875rem;
    }

    .dashboard-card .card-body .table .text-muted small,
    .dashboard-card .card-body .table small {
        font-size: 0.75rem !important;
    }

    .dashboard-card .card-body > .d-flex.pt-3,
    .dashboard-card .card-body > .border-top.pt-3,
    .dashboard-card .card-body > .d-flex.justify-content-end.pt-3 {
        padding-top: 0.5rem !important;
        margin-top: 0.25rem;
    }

    .dashboard-card .card-body .h4 {
        font-size: 1.125rem !important;
        margin-bottom: 0.375rem !important;
    }

    .dashboard-card .card-body dl.small {
        margin-top: 0.5rem !important;
        margin-bottom: 0 !important;
    }

    .dashboard-card .card-body dl.small dt {
        font-size: 0.75rem;
        margin-bottom: 0.05rem;
    }

    .dashboard-card .card-body dl.small dd {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }

    .dashboard-card .card-body dl.small dd:last-child {
        margin-bottom: 0;
    }

    .invoice-payment-tracker {
        margin-bottom: 0.625rem !important;
    }

    .invoice-payment-tracker .progress {
        height: 7px !important;
        margin-bottom: 0.375rem !important;
    }

    .invoice-payment-tracker .d-flex.mb-2 {
        margin-bottom: 0.25rem !important;
    }

    .invoice-payment-tracker .alert {
        margin-top: 0.5rem !important;
        padding: 0.4rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    .invoice-progress-steps {
        font-size: 0.6875rem !important;
        gap: 0.25rem;
    }

    /* Checkout order summary sidebar */
    .order-summary-card {
        padding: 0.875rem !important;
        margin-top: 0.75rem !important;
        border-radius: 8px;
    }

    .order-summary-card .section-title,
    .order-summary-card h3 {
        margin-bottom: 0.5rem !important;
        padding-bottom: 0.375rem !important;
        font-size: 0.75rem !important;
    }

    .order-summary-card .order-items {
        margin-bottom: 0.5rem !important;
    }

    .order-summary-card .order-item-small {
        margin-bottom: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }

    .order-summary-card .item-image-small img,
    .order-summary-card .item-image-small > div {
        width: 36px !important;
        height: 36px !important;
    }

    .order-summary-card .item-image-small {
        margin-right: 0.375rem !important;
    }

    .order-summary-card .price-breakdown .d-flex {
        margin-bottom: 0.25rem !important;
        font-size: 0.75rem;
    }

    .order-summary-card .price-breakdown hr {
        margin: 0.375rem 0 !important;
    }

    .order-summary-card .price-breakdown .fs-5 {
        font-size: 0.875rem !important;
    }

    .order-summary-card .price-breakdown .fs-4 {
        font-size: 1rem !important;
    }

    .checkout-section {
        padding: 0.875rem !important;
    }

    .checkout-section .section-title {
        margin-bottom: 0.75rem !important;
        padding-bottom: 0.375rem !important;
    }

    .address-card,
    .payment-option {
        padding: 0.625rem !important;
    }

    /* Detail rows (status / payment / delivery side panels) */
    .dashboard-card .card-body .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .dashboard-card .card-body .mb-2 {
        margin-bottom: 0.375rem !important;
    }

    .dashboard-card .card-body .badge.fs-6 {
        font-size: 0.6875rem !important;
    }

    /* Invoice document & cards with padded body (no separate card-header) */
    .dashboard-card.invoice-document,
    .dashboard-card > .card-body.p-3,
    .dashboard-card > .card-body.p-4 {
        padding: 0 !important;
    }

    .dashboard-card.invoice-document .card-body,
    .dashboard-card > .card-body.p-3,
    .dashboard-card > .card-body.p-4 {
        padding: 0.625rem !important;
    }

    .dashboard-card.invoice-document .mb-4,
    .dashboard-card.invoice-document .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .dashboard-card.invoice-document .pb-3 {
        padding-bottom: 0.5rem !important;
    }

    .dashboard-card.invoice-document h4 {
        font-size: 0.9375rem !important;
    }

    .dashboard-card.invoice-document .h5 {
        font-size: 0.875rem !important;
    }

    .cart-totals-strip .cart-subtotal-amount {
        font-size: 1rem !important;
        margin-bottom: 0.375rem !important;
    }

    /* Tables directly under card-header (admin order detail, etc.) */
    .dashboard-card:has(> .card-header + .table-responsive) {
        padding: 0.625rem 0.5rem 0.5rem !important;
    }

    .dashboard-card:has(> .card-header + .table-responsive) > .card-header {
        margin-bottom: 0.375rem !important;
        padding-bottom: 0.375rem !important;
    }

    .dashboard-card > .table-responsive .table th,
    .dashboard-card > .table-responsive .table td,
    .dashboard-card > .table-responsive table.table-pro th,
    .dashboard-card > .table-responsive table.table-pro td {
        padding: 0.3rem 0.35rem !important;
        font-size: 0.75rem !important;
    }

    .dashboard-card > .table-responsive .table thead th,
    .dashboard-card > .table-responsive table.table-pro thead th {
        font-size: 0.65625rem !important;
    }

    /* List-group line items (chef order view) */
    .dashboard-card .list-group-item {
        padding: 0.4rem 0.5rem !important;
        font-size: 0.75rem;
    }

    .dashboard-card .list-group-item .fw-semibold {
        font-size: 0.75rem;
    }

    .dashboard-card .list-group-item .small {
        font-size: 0.65625rem !important;
    }

    .dashboard-card .card-body .list-group + .d-flex.mt-3 {
        margin-top: 0.5rem !important;
        font-size: 0.75rem;
    }

    .dashboard-card .card-body .list-group + .d-flex .h5 {
        font-size: 0.875rem !important;
        margin-top: 0.25rem !important;
    }
}

@media (max-width: 575.98px) {
    .dashboard-card:has(> .card-header + .card-body) {
        padding: 0.5rem 0.5rem 0.375rem !important;
    }

    .dashboard-card .card-body .table:not(.order-line-table) th,
    .dashboard-card .card-body .table:not(.order-line-table) td,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) thead th,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) tbody td,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) tfoot td {
        padding: 0.25rem 0.3rem !important;
        font-size: 0.8125rem !important;
    }

    .dashboard-card .card-body .order-line-table th,
    .dashboard-card .card-body .order-line-table td {
        font-size: 0.8125rem !important;
    }

    .dashboard-card .card-body .table:not(.order-line-table) thead th,
    .dashboard-card .card-body table.table-pro:not(.order-line-table) thead th {
        font-size: 0.6875rem !important;
    }

    .dashboard-card .card-body .order-line-table thead th {
        font-size: 0.6875rem !important;
    }

    .order-summary-card {
        padding: 0.75rem !important;
    }

    .checkout-section {
        padding: 0.75rem !important;
    }
}

/* Final override: line-item tables — tight columns, readable text */
@media (max-width: 767.98px) {
    .dashboard-card .table.order-line-table thead th,
    .dashboard-card .table.order-line-table tbody td,
    .dashboard-card .table.order-line-table tfoot td,
    .table-responsive .table.order-line-table thead th,
    .table-responsive .table.order-line-table tbody td,
    .table-responsive .table.order-line-table tfoot td,
    .invoice-document .order-line-table thead th,
    .invoice-document .order-line-table tbody td,
    .invoice-document .order-line-table tfoot td {
        padding: 0.2rem 0.1rem !important;
        font-size: 0.875rem !important;
        line-height: 1.35 !important;
    }

    .dashboard-card .table.order-line-table thead th,
    .table-responsive .table.order-line-table thead th,
    .invoice-document .order-line-table thead th {
        font-size: 0.75rem !important;
        white-space: normal !important;
    }

    .dashboard-card .table.order-line-table thead th:nth-child(2),
    .dashboard-card .table.order-line-table tbody td:nth-child(2),
    .table-responsive .table.order-line-table thead th:nth-child(2),
    .table-responsive .table.order-line-table tbody td:nth-child(2) {
        width: 1.5rem !important;
        max-width: 1.5rem !important;
        padding-left: 0.04rem !important;
        padding-right: 0.04rem !important;
    }

    .dashboard-card .table.order-line-table thead th:nth-child(3),
    .dashboard-card .table.order-line-table tbody td:nth-child(3),
    .dashboard-card .table.order-line-table tfoot td:last-child,
    .table-responsive .table.order-line-table thead th:nth-child(3),
    .table-responsive .table.order-line-table tbody td:nth-child(3),
    .table-responsive .table.order-line-table tfoot td:last-child,
    .invoice-document .order-line-table thead th:nth-child(3),
    .invoice-document .order-line-table tbody td:nth-child(3),
    .invoice-document .order-line-table tfoot td:last-child {
        width: 5.75rem !important;
        max-width: 5.75rem !important;
        padding-left: 0.06rem !important;
        padding-right: 0 !important;
    }

    .dashboard-card .table.order-line-table thead th:nth-child(1),
    .dashboard-card .table.order-line-table tbody td:nth-child(1),
    .table-responsive .table.order-line-table thead th:nth-child(1),
    .table-responsive .table.order-line-table tbody td:nth-child(1) {
        padding-left: 0 !important;
        padding-right: 0.1rem !important;
    }

    .dashboard-card .table.order-line-table tfoot .h5,
    .table-responsive .table.order-line-table tfoot .h5 {
        font-size: 0.9375rem !important;
    }
}

/* Mobile readability floor — wins over dashboard inline .table rules */
@media (max-width: 767.98px) {
    .dashboard-card .table thead th,
    .dashboard-card .table tbody td,
    .dashboard-card .table tfoot td {
        font-size: 0.875rem !important;
    }

    .dashboard-card .table thead th {
        font-size: 0.75rem !important;
    }

    .content-wrapper,
    .main-content {
        font-size: 1rem;
    }
}

/* ── Meal image upload preview (chef forms) ── */
.meal-upload-preview {
    width: 100%;
    max-width: 360px;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    display: block;
}

/* ── Meal photo hover zoom ── */
.meal-image-zoom-wrap {
    overflow: hidden;
    width: 100%;
    display: block;
    line-height: 0;
}

.meal-image-zoom-wrap img,
.meal-image-zoom-wrap .meal-image,
.meal-image-zoom-wrap .meal-card-img,
.meal-image-zoom-wrap .heritage-image {
    width: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.45s ease;
    transform-origin: center center;
}

@media (hover: hover) and (pointer: fine) {
    .meal-image-zoom-wrap:hover img,
    .meal-image-zoom-wrap:hover .meal-image,
    .meal-image-zoom-wrap:hover .meal-card-img,
    .meal-image-zoom-wrap:hover .heritage-image {
        transform: scale(1.1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .meal-image-zoom-wrap img,
    .meal-image-zoom-wrap .meal-image,
    .meal-image-zoom-wrap .meal-card-img,
    .meal-image-zoom-wrap .heritage-image {
        transition: none;
    }

    .meal-image-zoom-wrap:hover img,
    .meal-image-zoom-wrap:hover .meal-image,
    .meal-image-zoom-wrap:hover .meal-card-img,
    .meal-image-zoom-wrap:hover .heritage-image {
        transform: none;
    }
}

/* ── Profile edit: side-by-side cards ── */
.profile-edit-row {
    align-items: stretch;
}

.profile-edit-card .card-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.625rem;
}

.profile-edit-card form {
    display: flex;
    flex-direction: column;
}

.profile-avatar-block .form-control[type="file"] {
    max-width: 100%;
}

@media (max-width: 991.98px) {
    .profile-edit-card .card-header {
        margin-bottom: 0.625rem;
    }
}

/* ── All Users table toolbar ── */
.all-users-card-header {
    padding-bottom: 0.625rem;
}

.all-users-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.625rem 1rem;
    width: 100%;
}

.all-users-table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-left: auto;
}

.all-users-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.all-users-toolbar-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #6e6e80;
    white-space: nowrap;
}

.all-users-pager-group .dropdown-toggle {
    min-width: 3.25rem;
    text-align: center;
}

@media (max-width: 767.98px) {
    .all-users-header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .all-users-table-toolbar {
        margin-left: 0;
        width: 100%;
        padding-top: 0.375rem;
        border-top: 1px solid #ececf1;
    }

    .all-users-pager-group {
        flex: 1 1 100%;
        justify-content: space-between;
    }

    .all-users-toolbar-group:not(.all-users-pager-group) {
        flex: 1 1 calc(50% - 0.375rem);
    }

    .all-users-toolbar-group:not(.all-users-pager-group) .btn {
        width: 100%;
    }
}

/* Toast notifications (cart, updates, success messages) */
.app-toast-stack {
    position: fixed;
    right: max(1.5rem, env(safe-area-inset-right));
    bottom: calc(max(1.5rem, env(safe-area-inset-bottom)) + 6.5rem);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: min(22rem, calc(100vw - 2rem));
    pointer-events: none;
}

/* Dashboard: below top-navbar profile (name + role) */
.app-toast-stack--profile {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    bottom: auto;
    left: auto;
    z-index: 1050;
}

.app-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.9375rem;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.app-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.app-toast i {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.app-toast--success {
    background: var(--primary-green, #22c55e);
}

.app-toast--error {
    background: #dc3545;
}

@media (max-width: 575.98px) {
    .app-toast-stack:not(.app-toast-stack--profile) {
        right: max(1rem, env(safe-area-inset-right));
        bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 6.25rem);
    }

    .app-toast-stack--profile {
        right: 0;
        max-width: min(20rem, calc(100vw - 1.5rem));
    }

    .app-toast {
        font-size: 0.875rem;
        padding: 0.65rem 1rem;
    }
}
