.tpe-shell {
    --tpe-primary: #0f62c2;
    --tpe-primary-soft: #e9f2ff;
    --tpe-text: #1d2a45;
    --tpe-muted: #6d7d98;
    --tpe-border: #dce6f4;
    --tpe-card-border: #e5edf8;
    --tpe-surface: #ffffff;
    --tpe-surface-soft: #f7faff;
    --tpe-success: #1f9d63;
    --tpe-warning: #d58512;
    --tpe-danger: #cd3347;
}

/* Fallback utilities for environments without Bootstrap 5 gap/gutter helpers */
.tpe-shell .gap-2 {
    gap: 0.5rem;
}

.tpe-shell .gap-3 {
    gap: 1rem;
}

.tpe-shell .row.g-3 {
    margin-right: -8px;
    margin-left: -8px;
}

.tpe-shell .row.g-3 > [class*="col-"] {
    padding-right: 8px;
    padding-left: 8px;
}

.tpe-shell .panel.tpe-panel {
    border: 1px solid var(--tpe-border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--tpe-surface);
    box-shadow: 0 10px 24px rgba(17, 43, 88, 0.07);
}

.tpe-shell .panel.tpe-panel .panel-hdr {
    min-height: auto;
    border-bottom: 1px solid var(--tpe-border);
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8fbff 0%, #f3f8ff 100%);
}

.tpe-shell .panel.tpe-panel .panel-hdr h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tpe-text);
}

.tpe-shell .panel.tpe-panel .panel-content {
    padding: 20px;
}

.tpe-shell .panel-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tpe-shell .panel-toolbar .btn {
    border-radius: 10px;
    font-weight: 600;
}

.tpe-shell .panel.tpe-panel .panel-hdr {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.tpe-shell .tpe-kpi-card {
    border: 1px solid var(--tpe-card-border);
    border-radius: 14px;
    background: var(--tpe-surface);
    padding: 14px 16px;
    height: 100%;
    box-shadow: 0 6px 16px rgba(20, 44, 86, 0.05);
}

.tpe-shell .tpe-kpi-label {
    color: var(--tpe-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.tpe-shell .tpe-kpi-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--tpe-text);
    line-height: 1.1;
    word-break: break-word;
}

.tpe-shell .tpe-kpi-sub {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--tpe-muted);
}

.tpe-shell .tpe-kpi-value.is-success {
    color: var(--tpe-success);
}

.tpe-shell .tpe-kpi-value.is-warning {
    color: var(--tpe-warning);
}

.tpe-shell .tpe-kpi-value.is-danger {
    color: var(--tpe-danger);
}

.tpe-shell .tpe-surface {
    border: 1px solid var(--tpe-card-border);
    border-radius: 14px;
    background: var(--tpe-surface);
    box-shadow: 0 6px 16px rgba(20, 44, 86, 0.04);
}

.tpe-shell .tpe-surface.tpe-surface-soft {
    background: var(--tpe-surface-soft);
}

.tpe-shell .tpe-section-title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--tpe-text);
}

.tpe-shell .tpe-progress-row {
    margin-bottom: 12px;
}

.tpe-shell .tpe-progress-row:last-child {
    margin-bottom: 0;
}

.tpe-shell .tpe-progress-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.82rem;
    color: var(--tpe-text);
}

.tpe-shell .tpe-progress {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e9eff8;
    overflow: hidden;
}

.tpe-shell .tpe-progress > span {
    display: block;
    height: 100%;
    border-radius: 999px;
}

.tpe-shell .tpe-progress > span.is-success {
    background: #21a96b;
}

.tpe-shell .tpe-progress > span.is-warning {
    background: #dd9315;
}

.tpe-shell .tpe-progress > span.is-danger {
    background: #d53a4d;
}

.tpe-shell .tpe-progress > span.is-primary {
    background: var(--tpe-primary);
}

.tpe-shell .tpe-metric-list {
    margin: 0;
    padding-left: 18px;
    color: var(--tpe-text);
}

.tpe-shell .tpe-metric-list li {
    margin-bottom: 8px;
}

.tpe-shell .tpe-metric-list li:last-child {
    margin-bottom: 0;
}

.tpe-shell .tpe-filter-bar {
    border: 1px solid var(--tpe-card-border);
    border-radius: 14px;
    background: var(--tpe-surface-soft);
    padding: 14px 14px 6px;
}

.tpe-shell .tpe-form-surface {
    border: 1px solid var(--tpe-card-border);
    border-radius: 14px;
    background: var(--tpe-surface);
    padding: 16px;
}

.tpe-shell .tpe-form-surface h4 {
    margin-bottom: 14px;
    font-size: 1rem;
    font-weight: 700;
}

.tpe-shell .tpe-table-wrap {
    border: 1px solid var(--tpe-card-border);
    border-radius: 14px;
    background: var(--tpe-surface);
    overflow: hidden;
}

.tpe-shell .table.tpe-table {
    margin-bottom: 0;
}

.tpe-shell .table.tpe-table thead th {
    border-bottom: 1px solid var(--tpe-border);
    background: #f4f8ff;
    color: #4f607d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.74rem;
    white-space: nowrap;
}

.tpe-shell .table.tpe-table td {
    border-color: #ecf1f8;
    color: var(--tpe-text);
    vertical-align: middle;
}

.tpe-shell .table.tpe-table tbody tr:nth-of-type(odd) {
    background: #fbfdff;
}

.tpe-shell .table.tpe-table tbody tr:hover {
    background: #f3f8ff;
}

.tpe-shell .badge {
    border-radius: 999px;
    font-weight: 700;
}

.tpe-shell .form-label {
    color: var(--tpe-text);
    font-weight: 600;
    font-size: 0.84rem;
}

.tpe-shell .form-control,
.tpe-shell .form-select {
    border: 1px solid #d5e1f1;
    border-radius: 10px;
    min-height: 40px;
    box-shadow: none;
}

.tpe-shell .form-control:focus,
.tpe-shell .form-select:focus {
    border-color: #6ca7ed;
    box-shadow: 0 0 0 0.2rem rgba(15, 98, 194, 0.15);
}

.tpe-shell .alert {
    border-radius: 12px;
}

.tpe-shell .tpe-pos-download-card {
    border: 1px solid var(--tpe-card-border);
    border-radius: 12px;
    background: #f9fbff;
    padding: 12px;
}

.tpe-shell .tpe-pos-download-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.tpe-shell .tpe-pos-download-body {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.tpe-shell .tpe-pos-download-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.tpe-shell .tpe-pos-download-text {
    font-size: 0.82rem;
    color: var(--tpe-text);
}

.tpe-shell .tpe-pos-url {
    margin-top: 8px;
    font-size: 0.74rem;
    color: var(--tpe-muted);
    word-break: break-word;
}

.tpe-shell .tpe-pos-qr-image {
    width: 124px;
    height: 124px;
    border: 1px solid #d8e4f4;
    border-radius: 10px;
    background: #fff;
    padding: 6px;
    object-fit: contain;
}

.tpe-shell .tpe-divider {
    margin: 14px 0;
    border-color: #dbe7f7;
}

.tpe-shell .tpe-pos-mini {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tpe-shell .tpe-pos-qr-mini {
    width: 90px;
    height: 90px;
    border: 1px solid #d8e4f4;
    border-radius: 10px;
    background: #fff;
    padding: 5px;
    object-fit: contain;
    flex: 0 0 auto;
}

.tpe-shell .tpe-pos-mini-copy {
    min-width: 0;
}

.tpe-shell .tpe-pos-empty {
    font-size: 0.82rem;
    color: var(--tpe-muted);
    background: #f2f6fc;
    border: 1px dashed #cfdaea;
    border-radius: 10px;
    padding: 8px 10px;
}

.tpe-shell .tpe-pos-empty a {
    color: #0f62c2;
    text-decoration: underline;
    font-weight: 600;
}

.tpe-shell .tpe-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tpe-shell .tpe-actions .btn {
    border-radius: 8px;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.28rem 0.55rem;
    line-height: 1.2;
    white-space: nowrap;
}

.tpe-shell .tpe-action-note {
    display: inline-block;
    font-size: 0.72rem;
    color: var(--tpe-muted);
    background: #f2f6fc;
    border: 1px dashed #cfdaea;
    border-radius: 999px;
    padding: 0.16rem 0.5rem;
}

.tpe-shell .tpe-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tpe-shell .tpe-page-subtitle {
    margin: 0;
    font-size: 0.83rem;
    color: var(--tpe-muted);
}

.tpe-shell .tpe-quick-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tpe-shell .tpe-quick-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0.34rem 0.8rem;
    border-radius: 999px;
    border: 1px solid #cfdbed;
    background: #f7faff;
    color: #315173;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.16s ease;
}

.tpe-shell .tpe-quick-link:hover {
    color: #0f4ba8;
    border-color: #bcd0ea;
    background: #edf4ff;
}

.tpe-shell .tpe-quick-link.is-active {
    color: #fff;
    border-color: #0f62c2;
    background: linear-gradient(135deg, #0f62c2 0%, #1c73d6 100%);
}

.tpe-shell .tpe-bulk-bar {
    border: 1px dashed #c8d8ee;
    border-radius: 12px;
    background: #f6faff;
    padding: 10px 12px;
}

.tpe-shell .tpe-kpi-card-terminal {
    position: relative;
    overflow: hidden;
}

.tpe-shell .tpe-kpi-card-terminal::after {
    content: "";
    position: absolute;
    inset: auto -18px -18px auto;
    width: 64px;
    height: 64px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(15, 98, 194, 0.15), rgba(15, 98, 194, 0));
}

.tpe-shell .tpe-kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.tpe-shell .tpe-kpi-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
    color: #135eb6;
    background: #e8f1ff;
}

.tpe-shell .tpe-kpi-icon.is-success {
    color: #1a8e58;
    background: #e6f7ee;
}

.tpe-shell .tpe-kpi-icon.is-primary {
    color: #fff;
    background: #2a79d7;
}

.tpe-shell .tpe-kpi-value.tpe-kpi-text {
    font-size: 1.02rem;
    line-height: 1.25;
}

.tpe-shell .tpe-form-surface-strong {
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.tpe-shell .tpe-form-surface.is-editing {
    border-color: #8fb7ea;
    box-shadow: 0 10px 26px rgba(15, 98, 194, 0.12);
}

.tpe-shell .tpe-form-header h4 {
    font-size: 1rem;
    font-weight: 700;
}

.tpe-shell .tpe-table-topbar {
    padding: 12px;
    border-bottom: 1px solid var(--tpe-card-border);
    background: #fbfdff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.tpe-shell .tpe-search-field {
    position: relative;
    min-width: 260px;
    flex: 1 1 320px;
}

.tpe-shell .tpe-search-field i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #8ba0bf;
    font-size: 0.82rem;
}

.tpe-shell .tpe-search-field .form-control {
    padding-left: 31px;
}

.tpe-shell .tpe-filter-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tpe-shell .tpe-filter-actions .btn {
    border-radius: 999px;
    font-weight: 700;
}

.tpe-shell .tpe-filter-actions .btn.is-active {
    color: #fff;
    background: var(--tpe-primary);
    border-color: var(--tpe-primary);
}

.tpe-shell .tpe-list-meta {
    padding: 8px 12px 10px;
    border-bottom: 1px solid var(--tpe-card-border);
    color: var(--tpe-muted);
    font-size: 0.8rem;
}

.tpe-shell .table.tpe-table tbody tr.tpe-row-default {
    background: #eef5ff;
}

.tpe-shell .table.tpe-table tbody tr.tpe-row-default:hover {
    background: #e7f0ff;
}

.tpe-shell .table.tpe-table tbody tr.tpe-row-editing,
.tpe-shell .table.tpe-table tbody tr.tpe-row-editing:hover {
    background: #eef7ff;
    box-shadow: inset 3px 0 0 #0f62c2;
}

.tpe-shell .table.tpe-table tbody tr.tpe-row-attention {
    background: #fff8e6;
}

.tpe-shell .table.tpe-table tbody tr.tpe-row-attention:hover {
    background: #fff2d2;
}

.tpe-shell .tpe-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.tpe-shell .tpe-pill.tpe-pill-primary {
    color: #0f56a6;
    background: #eaf3ff;
    border-color: #cfe2ff;
}

.tpe-shell .tpe-pill.tpe-pill-info {
    color: #0b7a8a;
    background: #e8f9fc;
    border-color: #beeef5;
}

.tpe-shell .tpe-pill.tpe-pill-neutral {
    color: #5a6f8f;
    background: #f1f5fb;
    border-color: #d8e3f2;
}

.tpe-shell .fw-semibold {
    font-weight: 600;
}

.tpe-shell code {
    word-break: break-all;
}

@media (max-width: 991.98px) {
    .tpe-shell .panel.tpe-panel .panel-content {
        padding: 16px;
    }

    .tpe-shell .panel-toolbar {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    .tpe-shell .panel.tpe-panel .panel-hdr {
        padding: 14px 14px;
    }

    .tpe-shell .panel.tpe-panel .panel-content {
        padding: 14px;
    }

    .tpe-shell .panel-toolbar .btn {
        flex: 1 1 calc(50% - 8px);
        min-width: 140px;
    }

    .tpe-shell .tpe-quick-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .tpe-shell .tpe-quick-link {
        flex: 0 0 auto;
    }

    .tpe-shell .tpe-actions .btn {
        flex: 1 1 calc(50% - 6px);
        justify-content: center;
    }

    .tpe-shell .tpe-bulk-bar .btn {
        flex: 1 1 100%;
    }

    .tpe-shell .tpe-bulk-bar .tpe-action-note {
        width: 100%;
        text-align: center;
    }

    .tpe-shell .tpe-filter-bar {
        padding: 12px 12px 8px;
    }

    .tpe-shell .tpe-table-topbar {
        padding: 10px;
    }

    .tpe-shell .tpe-search-field {
        min-width: 100%;
        flex-basis: 100%;
    }

    .tpe-shell .tpe-filter-actions {
        width: 100%;
    }

    .tpe-shell .tpe-filter-actions .btn {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 110px;
    }

    .tpe-shell .tpe-pos-download-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .tpe-shell .tpe-pos-download-body {
        flex-direction: column;
    }

    .tpe-shell .tpe-pos-mini {
        flex-direction: column;
    }

    .tpe-shell .tpe-reconcile-table thead,
    .tpe-shell .tpe-mobile-table thead {
        display: none;
    }

    .tpe-shell .tpe-reconcile-table tbody tr,
    .tpe-shell .tpe-mobile-table tbody tr {
        display: block;
        border-bottom: 1px solid #e3ecf8;
        padding: 8px 10px;
    }

    .tpe-shell .tpe-reconcile-table tbody td,
    .tpe-shell .tpe-mobile-table tbody td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        border: 0;
        padding: 6px 0;
        text-align: right;
    }

    .tpe-shell .tpe-reconcile-table tbody td::before,
    .tpe-shell .tpe-mobile-table tbody td::before {
        content: attr(data-label);
        color: #6f7f99;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        text-align: left;
        flex: 1 1 auto;
        max-width: 48%;
    }

    .tpe-shell .tpe-reconcile-table tbody td[data-label="Action"],
    .tpe-shell .tpe-reconcile-table tbody td[data-label="Details"],
    .tpe-shell .tpe-reconcile-table tbody td[data-label="Facture / Client"],
    .tpe-shell .tpe-mobile-table tbody td[data-label="Action"],
    .tpe-shell .tpe-mobile-table tbody td[data-label="Details"],
    .tpe-shell .tpe-mobile-table tbody td[data-label="Facture / Client"] {
        display: block;
        text-align: left;
    }

    .tpe-shell .tpe-reconcile-table tbody td[data-label="Action"]::before,
    .tpe-shell .tpe-reconcile-table tbody td[data-label="Details"]::before,
    .tpe-shell .tpe-reconcile-table tbody td[data-label="Facture / Client"]::before,
    .tpe-shell .tpe-mobile-table tbody td[data-label="Action"]::before,
    .tpe-shell .tpe-mobile-table tbody td[data-label="Details"]::before,
    .tpe-shell .tpe-mobile-table tbody td[data-label="Facture / Client"]::before {
        display: block;
        margin-bottom: 5px;
        max-width: none;
    }

    .tpe-shell .tpe-reconcile-table tbody td[data-label="Action"] .tpe-actions .btn,
    .tpe-shell .tpe-mobile-table tbody td[data-label="Action"] .tpe-actions .btn {
        flex: 1 1 100%;
    }

    .tpe-shell .tpe-reconcile-table tbody td[data-label="Selection"],
    .tpe-shell .tpe-mobile-table tbody td[data-label="Selection"] {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding: 2px 0;
    }

    .tpe-shell .tpe-reconcile-table tbody td[data-label="Selection"]::before,
    .tpe-shell .tpe-mobile-table tbody td[data-label="Selection"]::before {
        display: none;
    }

    .tpe-shell .tpe-reconcile-table tbody td[colspan],
    .tpe-shell .tpe-mobile-table tbody td[colspan] {
        display: block;
        text-align: center;
        padding: 10px 0;
    }

    .tpe-shell .tpe-reconcile-table tbody td[colspan]::before,
    .tpe-shell .tpe-mobile-table tbody td[colspan]::before {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .tpe-shell .panel-toolbar .btn {
        flex: 1 1 100%;
        min-width: 0;
    }

    .tpe-shell .tpe-filter-actions .btn {
        flex: 1 1 100%;
        min-width: 0;
    }

    .tpe-shell .tpe-actions .btn {
        flex: 1 1 100%;
        min-width: 0;
    }

    .tpe-shell .tpe-kpi-card {
        padding: 12px;
    }

    .tpe-shell .tpe-kpi-value {
        font-size: 1.14rem;
    }

    .tpe-shell .tpe-kpi-label {
        font-size: 0.74rem;
    }

    .tpe-shell .tpe-kpi-sub {
        font-size: 0.74rem;
    }

    .tpe-shell .table.tpe-table th,
    .tpe-shell .table.tpe-table td {
        padding: 0.45rem;
    }

    .tpe-shell .tpe-pill {
        min-width: 0;
    }
}
