:root {
    --apps-bg: rgba(15, 23, 42, 0.35);
    --apps-panel-bg: #ffffff;
    --apps-border-subtle: #e5e7eb;
    --apps-border-strong: #d1d5db;
    --apps-muted: #6b7280;
    --apps-heading: #111827;
    /* --apps-accent: #EB0E93; */
    --apps-accent: #EB0E93 ;
    --apps-accent-soft: rgba(226, 20, 71, 0.08);
    --apps-radius-lg: 18px;
    --apps-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.apps-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--apps-bg);
    display: flex;
    justify-content: flex-end;
    z-index: 1050;
    font-family: var(--apps-font);
}

.apps-modal-panel {
    position: relative;
    width: min(980px, 100%);
    max-width: 980px;
    background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
    box-shadow: -18px 0 40px rgba(15, 23, 42, 0.18);
    animation: appsSlideIn 0.25s ease-out;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    border-radius: 24px 0 0 24px;
    color: var(--apps-heading);
    overflow: hidden;
}

@media(max-width: 767px) {
    .apps-modal-panel {
        height: calc(100vh - 33px) !important;
    }
}

@keyframes appsSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.apps-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--apps-border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(14px);
}

.apps-modal-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.apps-app-logo {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: #eef2ff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.apps-app-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.apps-modal-title h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
}

.apps-modal-title p {
    margin: 0;
    font-size: 13px;
    color: var(--apps-muted);
    max-width: 480px;
}

.apps-modal-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--apps-accent-soft);
    color: var(--apps-accent);
    margin-bottom: 6px;
    text-decoration: none;
}

.apps-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.apps-modal-close {
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
}

.apps-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 24px 18px;
    /* ← sin el padding-bottom grande */
    font-size: 13px;
}

.apps-section {
    margin-bottom: 18px;
    background: none !important;
}

.apps-section-header h3 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
}

.apps-section-header p {
    margin: 0;
    font-size: 13px;
    color: var(--apps-muted);
}

.apps-card {
    background: #ffffff;
    border-radius: var(--apps-radius-lg);
    border: 1px solid var(--apps-border-subtle);
    padding: 14px 16px 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
    margin-top: 10px;
}

.apps-card-body {
    margin-top: 2px;
}

.form-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--apps-border-strong);
    padding: 7px 10px;
    font-size: 13px;
    outline: none;
    background: #ffffff;
}

.form-control:focus {
    border-color: var(--apps-accent);
    box-shadow: 0 0 0 1px rgba(226, 20, 71, 0.15);
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: var(--apps-muted);
}

/* FILAS DE ENVÍO */
.apps-shipping-rows-header {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) 32px;
    font-size: 11px;
    color: var(--apps-muted);
    margin-bottom: 4px;
    padding: 0 2px;
}

.apps-shipping-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.apps-shipping-row {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) 32px;
    gap: 6px;
    align-items: center;
}

.apps-row-remove-btn {
    border-radius: 999px;
    border: 1px solid var(--apps-border-strong);
    background: #ffffff;
    width: 26px;
    height: 26px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
}

.btn-ghost-xs {
    border: none;
    background: transparent;
    font-size: 12px;
    cursor: pointer;
    color: var(--apps-accent);
    padding: 6px 4px 0;
}

/* IMPORTADORES */
.apps-import-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 768px) {
    .apps-import-grid {
        grid-template-columns: 1fr;
    }

    .apps-modal-panel {
        border-radius: 0;
    }
}

.apps-import-card {
    border-radius: 16px;
    border: 1px solid var(--apps-border-subtle);
    background: #f9fafb;
    padding: 14px 12px 12px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.apps-import-card h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.apps-import-card p {
    margin: 0;
    font-size: 12px;
    color: var(--apps-muted);
}

.apps-import-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid var(--apps-border-subtle);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apps-import-icon-inner {
    font-size: 20px;
    color: var(--apps-muted);
}

.apps-import-upload {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.apps-import-upload-input {
    display: none;
}

.apps-import-upload-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--apps-border-strong);
    background: #ffffff;
    font-size: 13px;
    cursor: pointer;
}

.apps-import-upload-text {
    font-size: 11px;
    color: var(--apps-muted);
}

.apps-import-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

/* FOOTER */
.apps-modal-footer {
    position: static;
    /* ← reemplaza el absolute */
    flex-shrink: 0;
    padding: 10px 24px 14px;
    border-top: 1px solid var(--apps-border-subtle);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
}

.apps-footer-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--apps-muted);
}

.apps-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* BOTONES GENERALES */
.btn-primary,
.btn-outline-primary,
.btn-ghost {
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 13px;
    border-width: 1px;
    border-style: solid;
    cursor: pointer;
    font-weight: 500;
    background: transparent;
    font-family: var(--apps-font);
}

.btn-primary {
    background: var(--apps-accent);
    border-color: var(--apps-accent);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--apps-accent);
    border-color: var(--apps-accent);
}

.btn-outline-primary {
    border-color: var(--apps-accent);
    color: var(--apps-accent);
    background: #ffffff;
}

.szm-rates-page-button,
.szm-rates-page-button:hover,
.szm-rates-page-button:disabled,
.szm-rates-page-button:disabled:hover {
    border-color: var(--apps-accent);
    color: var(--apps-accent);
}

.szm-rates-page-button:hover,
.szm-rates-page-button:disabled:hover {
    background: var(--apps-accent-soft);
}

.szm-rates-page-button:disabled,
.szm-rates-page-button:disabled:hover {
    opacity: 1;
    cursor: not-allowed;
}

.btn-ghost {
    border-color: transparent;
    color: var(--apps-muted);
    background: transparent;
}

/* Quitar el padding del card cuando contiene la tabla */
.apps-card:has(.wf-table) {
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tabla sin bordes propios, hereda el card */
.wf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.wf-table thead {
    background: #f9fafb;
    border-bottom: 1px solid var(--apps-border-subtle);
}

.wf-table thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--apps-muted);
    white-space: nowrap;
}

.wf-table tbody tr {
    border-bottom: 1px solid var(--apps-border-subtle);
    transition: background 0.15s;
}

.wf-table tbody tr:last-child {
    border-bottom: none;
}

.wf-table tbody tr:hover {
    background: #f9fafb;
}

.wf-table tbody td {
    padding: 11px 16px;
    vertical-align: middle;
}

/* Toolbar encima de la card, no dentro */
.wf-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.wf-search {
    width: 220px;
}

.wf-select {
    width: 150px;
}

.wf-btn-new {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* Pills */
.wa-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.apps-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

.apps-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.apps-status-active {
    background: #f0fdf4;
    color: #15803d;
}

.apps-status-active .apps-status-dot {
    background: #22c55e;
}

.apps-status-inactive {
    background: #fef2f2;
    color: #dc2626;
}

.apps-status-inactive .apps-status-dot {
    background: #ef4444;
}

/* Botones icono */
.wf-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--apps-border-strong);
    background: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--apps-muted);
    transition: all 0.15s;
}

.btn-icon:hover {
    border-color: var(--apps-accent);
    color: var(--apps-accent);
    background: var(--apps-accent-soft);
}

.wf-btn-delete:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

/* Footer paginación */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--apps-border-subtle);
    background: #fafafa;
    font-size: 12px;
    color: var(--apps-muted);
    border-radius: 0 0 var(--apps-radius-lg) var(--apps-radius-lg);
}

.pagination {
    display: flex;
    gap: 4px;
}

.page-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--apps-border-strong);
    background: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: var(--apps-font);
    color: var(--apps-heading);
    transition: all 0.15s;
}

.page-btn:hover {
    border-color: var(--apps-accent);
    color: var(--apps-accent);
}

.page-btn.active {
    background: var(--apps-accent);
    border-color: var(--apps-accent);
    color: #fff;
}

/* Columnas con ancho fijo para que no bailen */
.wf-table th:nth-child(1),
.wf-table td:nth-child(1) {
    width: 40px;
}

.wf-table th:nth-child(2),
.wf-table td:nth-child(2) {
    width: 170px;
}

.wf-table th:nth-child(5),
.wf-table td:nth-child(5) {
    width: 90px;
}

.wf-table th:nth-child(6),
.wf-table td:nth-child(6) {
    width: 80px;
}

.contact-name {
    font-weight: 600;
    white-space: nowrap;
}

.contact-desc {
    color: var(--apps-muted);
    font-size: 12px;
    line-height: 1.5;
}

.wf-num {
    color: var(--apps-muted);
    font-size: 12px;
}

/* Carrusel de templates */
#tplTrack .tpl-card {
    flex-shrink: 0;
    width: calc(25% - 8px);
    /* 4 visibles */
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: #f9fafb;
    transition: border-color .2s;
}

@media (max-width: 767px) {
    #tplTrack .tpl-card {
        width: 100%;
        /* 1 visible */
    }
}

#tplTrack .tpl-card:hover {
    border-color: var(--apps-accent);
}

/* #tplTrack .tpl-card.selected {
    border-color: var(--apps-accent);
    box-shadow: 0 0 0 2px var(--apps-accent-soft);
} */

#tplTrack .tpl-card.is-selected {
    border-color: var(--apps-accent);
    box-shadow: 0 0 0 2px var(--apps-accent-soft);
}

#tplTrack .tpl-img-wrap {
    height: 72px;
    overflow: hidden;
}

#tplTrack .tpl-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#tplTrack .tpl-card-name {
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#tplTrack .tpl-selected-mark {
    display: none;
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--apps-accent);
    color: #fff;
    align-items: center;
    justify-content: center;
}

/* #tplTrack .tpl-card.selected .tpl-selected-mark {
    display: flex;
} */

#tplTrack .tpl-card.is-selected .tpl-selected-mark {
    display: flex;
}

.apps-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
    background: #d1d5db;
}

.apps-toggle.is-on {
    background: var(--apps-accent);
}

.apps-toggle input {
    display: none;
}

.apps-toggle-dot {
    position: absolute;
    width: 14px;
    height: 14px;
    top: 3px;
    left: 3px;
    background: #fff;
    border-radius: 50%;
    transition: left 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.apps-toggle.is-on .apps-toggle-dot {
    left: 19px;
    /* 36 - 14 - 3 = 19px */
}
