@media (max-width: 768px) {

    html,
    body {
        overflow-x: hidden;
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100%;
        -webkit-overflow-scrolling: touch;
    }

    body {
        padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
    }

    .btn-scan-mini {
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        color: #2F76BD;
        padding: 5px 10px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        transition: all 0.2s;
    }

    .btn-scan-mini:active {
        transform: scale(0.95);
        background: #e2e8f0;
    }

    .view-section {
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

/* [REMOVED DUPLICATE] Fixed Search Bar for Mobile reached by .search-container below */


/* [CLEANUP] Legacy search styles removed */

.invoice-brand {
    height: 100px;
}

/* === FORM UTILITIES === */
.form-group-mb-20 {
    margin-bottom: 20px;
}

.form-group-mb-15 {
    margin-bottom: 15px;
}

.form-group-mb-10 {
    margin-bottom: 10px;
}

.form-group-mb-25 {
    margin-bottom: 25px;
}

.btn-full-width {
    width: 100%;
    padding: 14px;
}

.text-right {
    text-align: right;
    margin-bottom: 25px;
}

.forgot-password-link {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

/* === FEATURE LOCKING (Upselling Strategy) === */
.feature-locked {
    opacity: 0.5 !important;
    filter: grayscale(1) !important;
    cursor: pointer !important;
    position: relative !important;
    pointer-events: auto !important;
    /* Ensure it's still clickable for the upgrade modal */
}

.feature-locked::after {
    content: '🔒';
    position: absolute;
    top: -8px;
    right: -8px;
    background: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.feature-locked i {
    color: var(--text-light) !important;
}

/* === LOGIN/AUTH LAYOUT (Modern Split) === */
/* =========================================
   ANIMACIONES PREMIUM (UX/UI Phase 3)
   ========================================= */

/* FADE IN */
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
    opacity: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* SKELETON LOADING */
.skeleton {
    background: #f1f5f9;
    background: linear-gradient(90deg,
            #f1f5f9 25%,
            #e2e8f0 50%,
            #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    display: inline-block;
    color: transparent !important;
    /* Hide text inside if any */
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Button Active State (Haptic Feel) */
.btn:active {
    transform: scale(0.96);
    transition: 0.1s;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.invoice-brand h2 {
    color: var(--primary);
    font-weight: 700;
    margin: 0;
    font-size: 1.8rem;
}

.invoice-brand p {
    color: var(--text-light);
    margin: 0;
    font-size: 0.9rem;
}

.invoice-meta {
    text-align: right;
}

.invoice-meta .status {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 5px 10px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 5px;
}

.invoice-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
}


/* KPIS (DISEÑO MARCA DE AGUA CORREGIDO) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-float);
}

.kpi-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 2;
    position: relative;
}

.kpi-value {
    font-size: 2.6rem;
    font-weight: 700;
    color: white;
    margin-top: 5px;
    z-index: 2;
    line-height: 1;
    position: relative;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.kpi-bg-icon {
    position: absolute;
    right: -20px;
    bottom: -35px;
    font-size: 160px;
    color: var(--primary);
    opacity: 0.06;
    transform: rotate(-15deg);
    z-index: 1;
    pointer-events: none;
}

/* TABLAS Y GRID - UNIFIED STYLE */
.table-wrap {
    background: rgba(255, 255, 255, 0.75) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
    border-radius: var(--radius);
    overflow: hidden;
    overflow-x: auto;
}

/* Special scrollable variant */
.table-wrap-scroll {
    max-height: 65vh !important;
    overflow-y: auto !important;
}

.search-container,
.dashboard-controls {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Repair Modal Premium Inputs */
.rc-input-premium {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.65);
    font-size: 0.85rem;
    color: var(--text-main);
    transition: all 0.2s;
    min-height: 38px;
    line-height: 1.4;
    box-sizing: border-box;
}

.rc-input-premium:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(211, 22, 40, 0.15);
    background: rgba(255, 255, 255, 0.95);
    outline: none;
}

.rc-input-premium[readonly] {
    cursor: default;
    background: rgba(255, 255, 255, 0.4);
    color: var(--text-main);
    font-weight: 700;
}

/* === IMEI HISTORY TRACKING UI === */
.imei-status-container {
    position: relative;
    display: flex;
    align-items: center;
}

.imei-badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 5;
    animation: slideInRight 0.3s ease-out;
}

.imei-badge.visible {
    display: flex;
}

.imei-badge-warranty {
    background: #fee2e2;
    color: #ef4444;
    border: 1px solid #fecaca;
}

.imei-badge-reentry {
    background: #fff7ed;
    color: #f59e0b;
    border: 1px solid #ffedd5;
}

.imei-badge i {
    font-size: 1rem;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* Clinical History Modal Refinements */
.history-timeline {
    padding: 20px;
}

.history-card {
    background: var(--bg-input);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.history-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 8px;
}

.history-date {
    font-weight: 800;
    color: var(--primary);
    font-size: 0.85rem;
}

.history-tech {
    font-size: 0.8rem;
    color: var(--text-light);
}

.history-body {
    font-size: 0.9rem;
    line-height: 1.4;
}

.history-footer {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* CASH AUDIT STYLES */
.audit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.audit-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
}

.audit-row.header {
    background: #f8fafc;
    font-weight: 700;
    color: #64748b;
    font-size: 0.8rem;
    padding: 8px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: none;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
}

.system-val {
    font-weight: 700;
    color: #475569;
    text-align: center;
}

.audit-input {
    width: 100%;
    max-width: 120px;
    text-align: right;
    font-weight: 700;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    font-size: 0.95rem;
    justify-self: end;
}

.audit-total-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    align-items: center;
    padding: 15px 15px;
    background: #f8fafc;
    border-radius: 12px;
    margin-top: 15px;
    font-weight: 800;
    font-size: 1.1rem;
    color: #1e293b;
}

#audit-usd-system-total,
#audit-ves-system-total {
    text-align: center;
}

#audit-usd-real-total,
#audit-ves-real-total {
    text-align: right;
}

.diff-val {
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 6px;
}

.diff-val.positive {
    color: #16a34a;
    background: #dcfce7;
}

.diff-val.negative {
    color: #dc2626;
    background: #fee2e2;
}

.glass-card {
    background: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

/* === REPAIR SWAL BUTTONS === */
.swal2-repair-actions .swal2-actions {
    width: 100% !important;
    justify-content: center !important;
    gap: 15px !important;
    flex-wrap: wrap !important;
}

.swal2-repair-actions .swal2-confirm,
.swal2-repair-actions .swal2-cancel {
    flex: 1 !important;
    min-width: 220px !important;
    /* Forces same width */
    max-width: 300px !important;
    font-size: 0.9rem !important;
    padding: 14px 20px !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
    /* Reset margins */
    margin: 0 !important;
}

.swal2-repair-actions .swal2-confirm:hover,
.swal2-repair-actions .swal2-cancel:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
}

/* Warranty Button Style (Orange/Amber Warning feel) */
.swal2-repair-actions .swal2-confirm {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3) !important;
    color: #fff !important;
    border: none !important;
}

/* New Repair Button Style (Clean Blue/Primary feel) */
.swal2-repair-actions .swal2-cancel {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3) !important;
    color: #fff !important;
    border: none !important;
}

/* Security mask for non-password fields to prevent autofill prompting */
.input-security-masked {
    -webkit-text-security: disc !important;
    text-security: disc !important;
}

/* GRID SPAN UTILITIES */
.grid-span-1 {
    grid-column: span 1 / span 1;
}
.grid-span-2 {
    grid-column: span 2 / span 2;
}
.grid-span-3 {
    grid-column: span 3 / span 3;
}
.grid-span-4 {
    grid-column: span 4 / span 4;
}